Back to Devexpress

ErrorBarsCollection Interface

officefileapi-devexpress-dot-spreadsheet-dot-charts-0c4255b5.md

latest5.2 KB
Original Source

ErrorBarsCollection Interface

A collection of error bars for the series.

Namespace : DevExpress.Spreadsheet.Charts

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public interface ErrorBarsCollection :
    ISimpleCollection<ErrorBarsOptions>,
    IEnumerable<ErrorBarsOptions>,
    IEnumerable,
    ICollection
vb
Public Interface ErrorBarsCollection
    Inherits ISimpleCollection(Of ErrorBarsOptions),
             IEnumerable(Of ErrorBarsOptions),
             IEnumerable,
             ICollection

The following members return ErrorBarsCollection objects:

Remarks

Error bars are displayed in the SpreadsheetControl only for the following chart types:

  • Column Clustered
  • Bar Clustered
  • Area
  • Line
  • Line with Markers
  • Stacked Line with Markers
  • 100% Stacked Line with Markers
  • Scatter
  • Scatter with Smooth Lines and Markers
  • Scatter with Smooth Lines
  • Scatter with Straight Lines and Markers
  • Scatter with Straight Lines

For other chart types, error bars can be accessed in code, exported in supported formats, and visualized in Microsoft Excel.

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 following error bar settings are available:

ValueTypeGets or sets the value type of the error bar.ValueGets or sets the error value.

The following properties are in effect only for the custom value type (ErrorBarsOptions.ValueType):

MinusGets or sets the negative error value.PlusGets or sets the positive error value.

The following properties allow you to customize the error bar’s appearance:

Outline Specifies the bar width and dash style.Fill Specifies the bar color.NoEndCapGets or sets whether the error bar has an end cap.

Note

Bars always run parallel to the Y axis (regardless of its orientation). The ErrorBarsOptions.BarDirection property has no effect.

Example

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

csharp
using DevExpress.Spreadsheet.Charts;
//... 
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);
    // Specify the error bar settings.
    errorBar.ValueType = ErrorBarValueType.Percentage;
    errorBar.Value = 10;
    errorBar.NoEndCap = true;

    workbook.SaveDocument("..\\..\\Result.xlsx");
}
vb
Imports DevExpress.Spreadsheet.Charts
'... 
Using workbook = New Workbook()
    workbook.LoadDocument("..\..\workbook.xlsx")
    Dim worksheet = workbook.Worksheets(0)

    ' Create a chart and specify its location.
    Dim chart As 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.
    Dim errorBar As ErrorBarsOptions = chart.Series(0).ErrorBars.Add(ErrorBarType.Both)
    ' Specify the error bar settings.
    errorBar.ValueType = ErrorBarValueType.Percentage
    errorBar.Value = 10
    errorBar.NoEndCap = True

    workbook.SaveDocument("..\..\Result.xlsx")
End Using

See Also

ErrorBarsCollection Members

DevExpress.Spreadsheet.Charts Namespace