Skip to main content

Bar Chart with Average Line

Bar chart with a horizontal average line overlaid across the bars
Legacy syntax
CustomChart {
fields {
field x {
type: 'dimension'
}
field legend {
type: 'dimension'
}
field y {
type: 'measure'
}
}
options {
}
template: @vgl {
"data": {"values": @{values}},
"layer": [{
"mark": {
"type": "bar",
"tooltip": true
},
"encoding": {
"x": {
"field": @{fields.x.name},
"axis": {
"format": @{fields.x.format},
"formatType": "holisticsFormat",
"labelAngle": 45
}
},
"y": {
"field": @{fields.y.name},
"type": "quantitative",
"axis": {
"format": @{fields.y.format},
"formatType": "holisticsFormat"
}
},
"xOffset": {
"field": @{fields.legend.name}
},
"color": {
"field": @{fields.legend.name}
},
}
}, {
"mark": "rule",
"encoding": {
"y": {
"aggregate": "mean",
"field": @{fields.y.name},
"type": "quantitative"
},
"color": {"value": "firebrick"},
"size": {"value": 3}
}
}],
};;
}

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