# Error Bars

Learn how to add error bars to Wijmo's chart components in this documentation topic

## Content


The __wijmo.chart.analytics__ module contains classes that extend the __Series__ class to provide extra information about the data including: trend lines, moving averages, error bars, box and waterfall plots, and function plots.

The __ErrorBar__ class extends the regular Series class to provide error bars that can be added on top of the regular series data.

To create a series with error bars, follow these steps:

1. Create an __ErrorBar__ series,
2. Configure the __ErrorBar__ series as you would regular series, setting their __binding__, __chartType__, and __style__ properties for example, and
3. Set the ErrorBar's __value__ and __errorAmount__ properties which determine the size of the error bars to be added to the data points.

Example:

```JavaScript
import * as chart from '@mescius/wijmo.chart';
import * as analytics from '@mescius/wijmo.chart.analytics';

// create an ErrorBar series for 15% and add it to the Chart
var errorBar = new analytics.ErrorBar();
errorBar.binding = 'amount';
errorBar.chartType = 'Column';
errorBar.value = 0.15;
errorBar.errorAmount = 'Percentage';
myChart.series.push(errorBar);
```

![Chart Error Bars](https://cdn.mescius.io/document-site-files/images/3c7113e2-10b3-45ed-8f3b-9fb1e0af2b74/chart/chart-error-bars.png)

Supported chart types for error bars:

* Column
* Bar
* Line
* LineSymbols
* Spline
* Area
* AreaSpline

## Supported Error Amounts

The __errorAmount__ property specifies the meaning of the __value__ property. Use any of the following error amount definitions:

* __FixedValue__: The value property represents the error as an absolute value.
* __Percentage__: The value property represents the error as a percentage.
* __StandardDeviation__: The value property represents the error as a number of standard deviations.
* __StandardError__: The error is the standard error of the mean (value property is not used).
* __Custom__: Error values are bound through the __binding__ property or set to an object with 'plus' and 'minus' values.

## Custom Error Amounts

Rather than setting a static value amount for all error bars, you can also provide custom error amounts within the data set and bind it to the __ErrorBar__ series. This is done through the __binding__ property or set to an object with 'plus' and 'minus' values.

Example:

```JavaScript
import * as chart from '@mescius/wijmo.chart';
import * as analytics from '@mescius/wijmo.chart.analytics';

var errorBar = new analytics.ErrorBar();
errorBar.binding = 'amount,errorPlus,errorMinus';
errorBar.chartType = 'Column';
myChart.series.push(errorBar);
```

In this example, the bound data object has at least three fields: amount, errorPlus and errorMinus

## Styling the Error Bars

Modify the error bars appearance by setting the __errorBarStyle__ property to an object including SVG style attributes (stroke, strokeWidth). You can set the direction of the error bars by setting the __direction__ property. You can also toggle the visibility of end-caps on the lines by setting the __endStyle__ enum.

Example:

```JavaScript
errorBar.direction = 'Both'; // 'Minus' or 'Plus'
errorBar.endStyle = 'NoCap'; // 'Cap'
errorBar.errorBarStyle = {
    stroke: 'darkred',
    strokeWidth: 3
  };
```
