Hi Team,
In waterfall chart, the axis title does not appear in bold by default, unlike other charts such as column and bubble charts.
Waterfall:
image.png (95.4 KB)
Column:
image.png (88.6 KB)
Bubble:
image.png (107.6 KB)
Attached Aspose program below:
Waterfall chart:
public static void main(String[] args) {
try {
// Create a new workbook
Workbook workbook = new Workbook();
// Get the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
// Add headers
cells.get("A1").putValue("Category");
cells.get("B1").putValue("Value");
// Sample data for waterfall chart
String[] categories = {"Start", "Q1 Growth", "Q2 Growth", "Q3 Loss", "Q4 Growth", "End"};
double[] values = {100000, 25000, 32000, -15000, 28000, 0};
// Populate data
for (int i = 0; i < categories.length; i++) {
cells.get(i + 1, 0).putValue(categories[i]);
cells.get(i + 1, 1).putValue(values[i]);
}
// Create waterfall chart
int chartIndex = worksheet.getCharts().add(com.aspose.cells.ChartType.WATERFALL, 5, 0, 20, 8);
Chart chart = worksheet.getCharts().get(chartIndex);
// Set data range for chart
chart.getNSeries().add("B2:B7", true);
chart.getNSeries().setCategoryData("A2:A7");
// Configure chart appearance
chart.getTitle().setText("Financial Waterfall Analysis");
chart.setShowLegend(false);
// Configure axes
chart.getCategoryAxis().getTitle().setText("Quarter");
chart.getValueAxis().getTitle().setText("Sales Amount");
chart.getValueAxis().getMajorGridLines().setVisible(true);
// Enable and configure data labels
chart.getNSeries().get(0).getDataLabels().setShowValue(true);
chart.getNSeries().get(0).getDataLabels().setNumberFormat("#,##0");
// Save the workbook
workbook.save("simple_waterfall_chart_axes.xlsx", SaveFormat.XLSX);
System.out.println("Simple waterfall chart created successfully: simple_waterfall_chart.xlsx");
} catch (Exception e) {
e.printStackTrace();
}
}
Column chart:
public static void main(String[] args) {
try {
// Create a new workbook
Workbook workbook = new Workbook();
// Get the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
// Add headers
cells.get("A1").putValue("Category");
cells.get("B1").putValue("Value");
// Sample data for column chart
String[] categories = {"Q1", "Q2", "Q3", "Q4"};
double[] values = {25000, 32000, 28000, 35000};
// Populate data
for (int i = 0; i < categories.length; i++) {
cells.get(i + 1, 0).putValue(categories[i]);
cells.get(i + 1, 1).putValue(values[i]);
}
// Create column chart
int chartIndex = worksheet.getCharts().add(com.aspose.cells.ChartType.COLUMN, 5, 0, 20, 8);
Chart chart = worksheet.getCharts().get(chartIndex);
// Set data range for chart
chart.setChartDataRange("A1:B5", true);
// Configure chart appearance
chart.getTitle().setText("Quarterly Sales Report");
chart.setShowLegend(true);
// Configure axes
chart.getCategoryAxis().getTitle().setText("Quarter");
chart.getValueAxis().getTitle().setText("Sales Amount");
chart.getValueAxis().getMajorGridLines().setVisible(true);
// Enable and configure data labels
chart.getNSeries().get(0).getDataLabels().setShowValue(true);
chart.getNSeries().get(0).getDataLabels().setNumberFormat("#,##0");
// Save the workbook
workbook.save("simple_column_chart.xlsx", SaveFormat.XLSX);
System.out.println("Simple column chart created successfully: simple_column_chart.xlsx");
} catch (Exception e) {
e.printStackTrace();
}
}
Bubble Chart:
public static void main(String[] args) {
try {
// Create a new workbook
Workbook workbook = new Workbook();
// Get the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
// Add headers
cells.get("A1").putValue("Product");
cells.get("B1").putValue("Sales");
cells.get("C1").putValue("Profit");
cells.get("D1").putValue("Market Share");
// Sample data for bubble chart
// Each bubble represents: X (Sales), Y (Profit), Size (Market Share)
String[] products = {"Product A", "Product B", "Product C", "Product D", "Product E"};
double[] sales = {30000, 45000, 25000, 60000, 35000};
double[] profit = {5000, 8000, 3000, 12000, 7000};
double[] marketShare = {15, 25, 10, 30, 20};
// Populate data
for (int i = 0; i < products.length; i++) {
cells.get(i + 1, 0).putValue(products[i]);
cells.get(i + 1, 1).putValue(sales[i]);
cells.get(i + 1, 2).putValue(profit[i]);
cells.get(i + 1, 3).putValue(marketShare[i]);
}
// Create bubble chart
int chartIndex = worksheet.getCharts().add(com.aspose.cells.ChartType.BUBBLE, 5, 0, 25, 10);
Chart chart = worksheet.getCharts().get(chartIndex);
// Add series for bubble chart
// X-values: Sales (Column B), Y-values: Profit (Column C), Bubble sizes: Market Share (Column D)
chart.getNSeries().add("B2:B6", true);
chart.getNSeries().get(0).setXValues("B2:B6");
chart.getNSeries().get(0).setValues("C2:C6");
chart.getNSeries().get(0).setBubbleSizes("D2:D6");
// Configure chart appearance
chart.getTitle().setText("Product Performance Analysis");
chart.setShowLegend(false);
// Configure axes
chart.getCategoryAxis().getTitle().setText("Sales ($)");
chart.getValueAxis().getTitle().setText("Profit ($)");
chart.getValueAxis().getMajorGridLines().setVisible(true);
// Enable and configure data labels to show product names
chart.getNSeries().get(0).getDataLabels().setShowCategoryName(true);
chart.getNSeries().get(0).getDataLabels().setShowValue(false);
// Save the workbook
workbook.save("simple_bubble_chart.xlsx", SaveFormat.XLSX);
System.out.println("Simple bubble chart created successfully: simple_bubble_chart.xlsx");
} catch (Exception e) {
e.printStackTrace();
}
}