[]
A waterfall chart shows the aggregate of values as they are added or subtracted.This type of chart is useful to understand how the initial value is affected by a series of positive and negative values.Waterfall charts can be used for viewing fluctuations in product earnings, net income or profit analysis.
Refer the following code for adding Waterfall chart.
private static void WaterfallChart() {
// Initialize workbook
Workbook workbook = new Workbook();
// Fetch default worksheet
IWorksheet worksheet = workbook.getWorksheets().get(0);
// Prepare data for chart
worksheet.getRange("A1:B8")
.setValue(new Object[][] {
{ "Starting Amt", 130 },
{ "Measurement 1", 25 },
{ "Measurement 2", -75 },
{ "Subtotal", 80 },
{ "Measurement 3", 45 },
{ "Measurement 4", -65 },
{ "Measurement 5", 80 },
{ "Total", 140 } });
worksheet.getRange("A:A").getColumns().autoFit();
// Add Waterfall Chart
IShape waterfallChartShape = worksheet.getShapes().addChart(ChartType.Waterfall, 300, 20, 300, 250);
waterfallChartShape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B8"));
// Configure Chart Title
waterfallChartShape.getChart().getChartTitle().setText("Waterfall Chart");
// Set subtotal & total points
IPoints points = waterfallChartShape.getChart().getSeriesCollection().get(0).getPoints();
points.get(3).setIsTotal(true);
points.get(7).setIsTotal(true);
// Connector lines are not shown
ISeries series = waterfallChartShape.getChart().getSeriesCollection().get(0);
series.setShowConnectorLines(false);
// Saving workbook to Xlsx
workbook.save("30-WaterfallChart.xlsx", SaveFileFormat.Xlsx);