# Error Bars

Learn how to add and customize error bars as per your requirements.

## Content

Error bars are graphical elements that are used to display the variability of data points. By using the [ErrorBars](/spreadnet/api/latest/online-win/FarPoint.Win.Chart/FarPoint.Win.Chart.ErrorBars.html) class properties and associated enums, you can add and customize error bars according to your specific requirements, ensuring an accurate representation of data in charts. Spread also provides support for import and export error bars in charts from/to XML and Excel formats.
To determine the direction of the error bars concerning the axes, use the [ErrorBarDirection](/spreadnet/api/latest/online-win/FarPoint.Win.Chart/FarPoint.Win.Chart.ErrorBarDirection.html) enum. It offers two values:

* **X**: Indicates that the bars run parallel to the Y-axis for X-axis values.
* **Y**: Indicates that the bars run parallel to the X-axis for Y-axis values.

Using the [ErrorBarType](/spreadnet/api/latest/online-win/FarPoint.Win.Chart/FarPoint.Win.Chart.ErrorBarType.html) enum, you can define the type of error bars. It includes three values:

* **Minus**: Represents an error bar with a negative error range.
* **Plus**: Represents an error bar with a positive error range.
* **Both**: Represents an error bar with both positive and negative error ranges.

To define the type of error value, use the [ErrorBarValueType](/spreadnet/api/latest/online-win/FarPoint.Win.Chart/FarPoint.Win.Chart.ErrorBarValueType.html) enum which consists of four values:

* **FixedValue**: Represents the error as an absolute value.
* **Percentage**: Represents the error as a percentage.
* **StandardDeviation**: Represents the error as a number of standard deviations.
* **StandardError**: Represents a standard error value.

Spread lets you use Error Bars in different chart series, such as:

* BarSeries
* LineSeries
* AreaSeries
* XYLineSeries
* XYPointSeries
* ClusteredBarSeries
* HighLowCloseSeries
* CandlestickSeries

## Using Code

The following sample code shows how to implement ErrorBar in ClusteredBarSeries in Spread.
**C#**

```csharp
fpSpread1.ActiveSheet.AddChart(new CellRange(0, 0, 3, 6), typeof(FarPoint.Win.Chart.ClusteredBarSeries), 600, 300, 50, 50);
fpSpread1.ActiveSheet.SetClip(0, 1, 1, 5, "1.2\\t0\\t-12.5\\t-5\\t15");
fpSpread1.ActiveSheet.SetClip(1, 0, 1, 6, "1\\t-15.43\\t-11\\t16\\t0\\t17.5");
fpSpread1.ActiveSheet.SetClip(2, 0, 1, 6, "2\\t7\\t12\\0\\t-10\\t10\\t0");
if (fpSpread1.ActiveSheet.Charts[0].Model.PlotAreas[0].Series[0] is ClusteredBarSeries cluster)
  {
    foreach (BarSeries series in cluster.Series)
    {
      ErrorBars errorBar = series.SetErrorBarsVisible(true);
      errorBar.ValueType = ErrorBarValueType.StandardError;
      errorBar.Type = FarPoint.Win.Chart.ErrorBarType.Both;
    }
  }
```

**VB**

```vbnet
FpSpread1.ActiveSheet.AddChart(New CellRange(0, 0, 3, 6), GetType(FarPoint.Win.Chart.ClusteredBarSeries), 600, 300, 50, 50)FpSpread1.ActiveSheet.SetClip(0, 1, 1, 5, "1.2" & vbTab & "0" & vbTab & "-12.5" & vbTab & "-5" & vbTab & "15")FpSpread1.ActiveSheet.SetClip(1, 0, 1, 6, "1" & vbTab & "-15.43" & vbTab & "-11" & vbTab & "16" & vbTab & "0" & vbTab & "17.5")FpSpread1.ActiveSheet.SetClip(2, 0, 1, 6, "2" & vbTab & "7" & vbTab & "12" & vbNullChar & vbTab & "-10" & vbTab & "10" & vbTab & "0")
Dim cluster As ClusteredBarSeries = Nothing
If CSharpImpl.__Assign(cluster, TryCast(FpSpread1.ActiveSheet.Charts(0).Model.PlotAreas(0).Series(0), ClusteredBarSeries)) IsNot Nothing Then
        For Each series As BarSeries In cluster.Series
            Dim errorBar As ErrorBars = series.SetErrorBarsVisible(True)
            errorBar.ValueType = ErrorBarValueType.StandardError
            errorBar.Type = FarPoint.Win.Chart.ErrorBarType.Both
        Next
End If
```

The following image depicts the output of the above code.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/errorbar.png)

## Customizing Error Bars in Spread Chart Designer

Spread provides functionality to customize error bars properties within the Chart Designer. Follow the steps below to access and modify error bars settings:

1. Right-click on the chart in the Spread Designer.
2. Click **Chart Designer...** from the menu that opens the **Spread Chart Designer** dialog.
3. From the left side panel, locate and click the Error Bars on which you want to make the changes.
    When selected, the property list will appear on the right side of the dialog.![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/edit_errorbar.png)
4. Customize the error bars values according to your requirements using the provided properties.

## Limitations

* Spread Designer does not support interactive user interface customization of error bars.
* Currently, the **ErrorBarValueType.Custom** enum is not supported for customization.

## See Also

[Chart User Interface Elements](/spreadnet/docs/latest/online-win/overview/spwin-devguide/fpchart-devguide/fpchart-chartsummary/fpchart-chart-uiparts)
[Chart Object Model](/spreadnet/docs/latest/online-win/overview/spwin-devguide/fpchart-devguide/fpchart-chartsummary/fpchart-chart-objects)
[Chart Types and Views](/spreadnet/docs/latest/online-win/overview/spwin-devguide/fpchart-devguide/fpchart-chartsummary/fpchart-chart-charttv)
[Plot Types](/spreadnet/docs/latest/online-win/overview/spwin-devguide/fpchart-devguide/fpchart-chartsummary/fpchart-plottypes)
[Plot area](/spreadnet/docs/latest/online-win/overview/spwin-devguide/fpchart-devguide/fpchart-chartsummary/fpchart-plotsseries)
[Labels](/spreadnet/docs/latest/online-win/overview/spwin-devguide/fpchart-devguide/fpchart-chartsummary/fpchart-style-labels)
[Legends](/spreadnet/docs/latest/online-win/overview/spwin-devguide/fpchart-devguide/fpchart-chartsummary/fpchart-style-legend)