AG Studio Launch Week šŸš€šŸš€šŸš€ 28 Sep - 2 Oct 2026 šŸš€šŸš€šŸš€ Join now

JavaScript ChartsError Bars

Version 14.2.0
Enterprise

Error Bars visually represent the variability or uncertainty of data, indicating the range within which data values might fall.

Single Error Bars Copy Link

This example adds Error Bars to a Bar Series using the errorBar series option:

{
    series: [
        {
            type: 'bar',
            xKey: 'month',
            yKey: 'dividends',
            errorBar: {
                yLowerKey: 'lowerCI',
                yUpperKey: 'upperCI',
            },
        },
    ],
}

In this configuration:

  • errorBar.yLowerKey maps to the lower bound of the confidence interval.
  • errorBar.yUpperKey maps to the upper bound of the confidence interval.

Error Bars are only supported in Bar, Line and Scatter series.

Double Error Bars Copy Link

This example adds Double Error Bars to a Line Series using the errorBar series option:

{
    series: [
        {
            type: 'line',
            xKey: 'expiry',
            yKey: 'price',
            errorBar: {
                xLowerKey: 'expiryLo',
                xUpperKey: 'expiryHi',
                yLowerKey: 'priceLo',
                yUpperKey: 'priceHi',
            },
            tooltip: { renderer: customTooltipRenderer },
        },
    ],
}

In this configuration:

  • errorBar.xLowerKey and errorBar.xUpperKey denote the x-axis bounds.
  • errorBar.yLowerKey and errorBar.yUpperKey denote the y-axis bounds.

A custom Tooltip is also provided to the series tooltip option to display the x-axis and y-axis bounds. The x and y keys and names are available to the renderer when Error Bars are enabled.

Double Error Bars require the x-axis to be a Number Axis, limiting them to Line and Scatter series.

Customisation Copy Link

This example shows different Error Bar Cap and Whiskers customisations:

{
    errorBar: {
        // ...
        stroke: 'pink', // Whisker stroke colour
        strokeWidth: 2, // Whisker stroke width
        cap: {
            stroke: 'red', // Cap stroke colour (otherwise inherits from whisker)
            strokeWidth: 5, // Cap stroke width (otherwise inherits from whisker)
            length: 25, // Cap length as an absolute width
        },
    },
}

The Cap length can also be customised as a ratio relative to series shape using lengthRatio.

The default Cap length is determined based on the type of series:

  • For Line and Scatter series, it defaults to the Marker size.
  • For Bar series, it defaults to 30% of the bar width.

Stylers can also be used for customisation using the errorBar.itemStyler property. The params object includes properties from the Series and Error Bars.

API Reference Copy Link

Properties available on the AgErrorBarOptions interface.

xLowerKey DatumKey
The key to use to retrieve lower bound error values from the x-axis data.
xUpperKey DatumKey
The key to use to retrieve upper bound error values from the x-axis data.
yLowerKey DatumKey
The key to use to retrieve lower bound error values from the y-axis data.
yUpperKey DatumKey
The key to use to retrieve upper bound error values from the y-axis data.
xLowerName string
Human-readable description of the lower bound error value for the x-axis. This is the value to use in tooltips or labels.
xUpperName string
Human-readable description of the upper bound error value for the x-axis. This is the value to use in tooltips or labels.
yLowerName string
Human-readable description of the lower bound error value for the y-axis. This is the value to use in tooltips or labels.
yUpperName string
Human-readable description of the upper bound error value for the y-axis. This is the value to use in tooltips or labels.
itemStyler Styler
Function used to return formatting for individual error bars, based on the given parameters.
cap ErrorBarCapOptions
Options to style error bars' caps
visible boolean
Whether to display the error bars.
stroke AgCssColorOrRef
The colour for the stroke.
strokeWidth PixelSize
The width of the stroke in pixels.
strokeOpacity Opacity
The opacity of the stroke colour.
lineDash PixelSize[]
An array specifying the length in pixels of alternating dashes and gaps.
lineDashOffset PixelSize
The initial offset of the dashed line in pixels.