﻿ Waterfall Chart | Documents for Excel .NET Edition | GCDocuments
Documents for Excel .NET Edition | GCDocuments
Features / Chart / Chart Types / Statistical Chart / Waterfall Chart
In This Topic
Waterfall Chart
In This Topic

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.

### Using Code

Refer the following code for adding Waterfall chart.

C#
Copy Code
```  public void WaterfallChart()
{
// Initialize workbook
Workbook workbook = new Workbook();
// Fetch default worksheet
IWorksheet worksheet = workbook.Worksheets[0];

// Prepare data for chart
worksheet.Range["A1:B8"].Value = 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.Range["A:A"].Columns.AutoFit();

IShape waterfallChartShape = worksheet.Shapes.AddChart(ChartType.Waterfall, 300, 20, 300, 250);

//Set subtotal & total points
IPoints points = waterfallChartShape.Chart.SeriesCollection[0].Points;
points[3].IsTotal = true;
points[7].IsTotal = true;

//Connector lines are not shown
ISeries series = waterfallChartShape.Chart.SeriesCollection[0];
series.ShowConnectorLines = false;

// Configure Chart Title
waterfallChartShape.Chart.ChartTitle.Text = "Waterfall Chart";

// Saving workbook to Xlsx
workbook.Save(@"30-WaterfallChart.xlsx", SaveFileFormat.Xlsx);
}```