Skip to main content

Error Bar

An error bar visualizes the uncertainty or degree of error in a reported measurement.

  • Good for: showing the spread or confidence around a mean per category, comparing variability across groups, summarizing repeated measurements.
  • Not great for: a single value with no spread (use a KPI or gauge), trends over time, or part-to-whole composition.

Syntax

Use the following AML definition to add the Error Bar to your custom chart library.

Legacy syntax
CustomChart {
fields {
field point {
type: "dimension"
label: "Points"
}
field variety {
type: "dimension"
label: "Variety"
}
}
template: @vgl
{
"data": {
"values": @{values}
},
"layer": [
{
"mark": {
"type": "point",
"filled": true
},
"encoding": {
"x": {
"type": "quantitative",
"field": @{fields.point.name},
"scale": {
"zero": false
},
"title": "Barley Yield",
"aggregate": "mean"
},
"color": {
"value": "black"
}
}
},
{
"mark": {
"type": "errorbar",
"extent": "ci"
},
"encoding": {
"x": {
"type": "quantitative",
"field": @{fields.point.name},
"title": "Barley Yield"
}
}
}
],
"encoding": {
"y": {
"type": "ordinal",
"field": @{fields.variety.name}
}
}
}
;;;
}

Required fields

An Error Bar expects exactly two fields. Each input row is one observation, and the template groups observations by category to compute the mean and spread.

FieldLabelTypeRole
valueValuedimensionNumeric observation on the x axis (data_type: 'number'). The mean sets the point, and the chosen extent sets the bar. Sorted ascending (apply_order: 1).
dimensionDimensiondimensionCategory on the y axis (one error bar per value). Sorted ascending (apply_order: 2).

Data requirements: Do not pre-aggregate. The template computes the mean and the error extent from the raw rows, so each category needs multiple observations for a meaningful spread.

Sample data:

valuedimension
42Region A
47Region A
39Region A
51Region B
55Region B
49Region B
33Region C
38Region C

Options

Set these options to adjust the chart without editing the Vega template. The CustomChartDef block above declares each option's type and allowed values.

OptionDefaultEffect
point_color#255DD4Fill color of the mean point marker.
extentciHow the template computes the error bar length (confidence interval, standard error, standard deviation, or interquartile range).

Known limitations

  • Needs multiple rows per category. The bar reflects spread across observations, so a single row per category produces a point with no visible error bar.

  • The center point is always the mean of value. Showing a median or another statistic requires editing the template.

  • One dimension only. The chart plots one category axis. Comparing a second grouping (for example, by color) requires editing the template.


Open Markdown
Let us know what you think about this document :)