Back to Devexpress

How to Add Error Bars to a Chart Series

windowsforms-404754-controls-and-libraries-spreadsheet-examples-charts-how-to-add-error-bars-to-a-chart-series.md

latest1.5 KB
Original Source

How to Add Error Bars to a Chart Series

  • Dec 04, 2023

The example shows how to add error bars for a chart series.

Follow the steps below to create an error bar:

  1. Call the Add method to create an error bar for a chart series.

  2. Specify the properties of the created ErrorBarsOptions object.

The code sample below creates error bars for a line chart:

csharp
using DevExpress.Spreadsheet.Charts;
//... 
spreadsheetControl1.LoadDocument("Document.xlsx");

var chart1 = spreadsheetControl1.ActiveWorksheet.Charts[0];
ErrorBarsOptions errorBar = chart1.Series[0].ErrorBars.Add(ErrorBarType.Both);
//Specify the error type and value
errorBar.ValueType = ErrorBarValueType.Percentage;
errorBar.Value = 10;
//Specify error bar settings
errorBar.NoEndCap = true;
vb
Imports DevExpress.Spreadsheet.Charts
'... 
spreadsheetControl1.LoadDocument("Document.xlsx")

Dim chart1 = spreadsheetControl1.ActiveWorksheet.Charts(0)
Dim errorBar As ErrorBarsOptions = chart1.Series(0).ErrorBars.Add(ErrorBarType.Both)
'Specify the error type and value
errorBar.ValueType = ErrorBarValueType.Percentage
errorBar.Value = 10
'Specify error bar settings
errorBar.NoEndCap = True