Skip to main content
A newer version of this page is available. .
All docs
V21.1
.NET Framework 4.5.2+

ErrorBarsCollection.Add(ErrorBarType) Method

Adds a new error bar to the series.

Namespace: DevExpress.Spreadsheet.Charts

Assembly: DevExpress.Spreadsheet.v21.1.Core.dll

Declaration

ErrorBarsOptions Add(
    ErrorBarType barType
)

Parameters

Name Type Description
barType ErrorBarType

An enumeration value that indicates the error bar type.

Returns

Type Description
ErrorBarsOptions

An object that contains options for the error bar.

Remarks

Note

The ErrorBarsCollection has no effect on the visual appearance of a chart when the document is loaded in the SpreadsheetControl. However, the property can be accessed in code, exported in supported formats and visualized in Microsoft Excel.

The code sample below creates error bars for a line chart (the result is opened in Microsoft Excel):

chart with error bars

using (var workbook = new Workbook()) 
{
    workbook.LoadDocument("..\\..\\workbook.xlsx");
    var worksheet = workbook.Worksheets[0];

    // Create a chart and specify its location.
    Chart chart = worksheet.Charts.Add(ChartType.LineMarker,worksheet["A1:B13"]);
    chart.TopLeftCell = worksheet.Cells["E2"];
    chart.BottomRightCell = worksheet.Cells["K14"];
    chart.Legend.Visible = false;

    // Create an error bar
    ErrorBarsOptions errorBar = chart.Series[0].ErrorBars.Add(ErrorBarType.Both);
    errorBar.NoEndCap = true;

    // Specify the error type and value
    errorBar.ValueType = ErrorBarValueType.Percentage;
    errorBar.Value = 10;
    workbook.SaveDocument("..\\..\\Result.xlsx");
}
See Also