Skip to content

Instantly share code, notes, and snippets.

@dm-p
Created Aug 20, 2022
Embed
What would you like to do?
Reproduction of "The Mundigl Bullets" using Deneb & Vega-Lite
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"usermeta": {
"deneb": {
"build": "1.3.0.0",
"metaVersion": 1,
"provider": "vegaLite",
"providerVersion": "5.2.0"
},
"interactivity": {
"tooltip": true,
"contextMenu": true,
"selection": false,
"highlight": false,
"dataPointLimit": 50
},
"information": {
"name": "Mundigl Bullet Chart",
"description": "An interpretation of the bullet chart variations by Robert Mundigl: https://www.clearlyandsimply.com/clearly_and_simply/2017/07/variations-of-alternative-bullet-graphs-in-excel.html",
"author": "Daniel Marsh-Patrick (inspired by Robert Mundigl)",
"uuid": "c7017285-b3cb-4633-b9ef-cb3cefa8c2fb",
"generated": "2022-08-20T05:23:38.967Z",
"previewImageBase64PNG": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAABKCAYAAABZ/a22AAAVyElEQVR4Xu1dDXRV1ZXe5/68927eC3kvCfkjQEBiaySADT+FzowyU6tTrC5K84JaLf0DbZVqyxR1FqK1U6etzNLIdJZMWxAVbaLjzLJrOR2HTltH1FVCVSAVQiAm5P/nJXm/9717z561LzzmGUjy7vvJe0DOWqwAOWefffb97jnn7vPtfRhMl2kLpMECLA0yp0XGWAARhe5du9YLivLfJXfe2Xe5GCcpYDU0NKwFgM2Xi7ESGSdjjFV0ds4bnDWrexQxmIiMMW1EANCTlYOITXV1dVuSlTNe+3iAxWpra+XGxsYwCdm48Qs5u3a9RgbCxsbGexGxPla4oijgcDiAcw6Dg4Pp0js75eo6AGMAggBw9u9MFKG8uxsGS0ogkKDWTqcTAoEAhMNhsFqtYLPZDEmhUAhUVU1QKrzhdrs/l2jjydp9DFhf+fKX14Cot6EmLBQAPuKcL+OofaSB2GUTRdUfDg85FHmpDtLBvXv3dhKwbDZb/bx580AU6UUCY+AELBpwR0cHnD59ejIdLvrf27q6IJKXB/LwMCAQthgAInBZ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kEQliHivak08Gc+85nVLpfrO319fQWUySUcDjPOOZdlmQeDQVGW5TcPHTr096nskzF2jYh476JTp15esHXrtqZPf3qVCHCzxet9VrVaC0GSKFuzlQtCSAqFDi86fDhtdOBUjitZWfEsheP2kSjRL40zFnnNt+q6/leRCMUw2MhdQEsiPUz6+Sxj7PVkjRbbnmaslX19n4hdCrPZDZDKsU8kK2PASscea6qMNrafifZYmdIp0/0mBazdu3fb8vLyiNRvqnzxi1+ky4UumTL0/PPVQY/nurJ77tk5/VV45rEmBaxLBhlJDmSq/FhJqjmlzf8PpAPT8GA7MOQAAAAASUVORK5CYII="
},
"dataset": [
{
"key": "__0__",
"name": "Category",
"description": "Category column for each bar",
"type": "text",
"kind": "column"
},
{
"key": "__1__",
"name": "Value",
"description": "Main bar value",
"type": "numeric",
"kind": "measure"
},
{
"key": "__2__",
"name": "Target",
"description": "Target value",
"type": "numeric",
"kind": "measure"
},
{
"key": "__3__",
"name": "Gap",
"description": "Gap to target",
"type": "numeric",
"kind": "measure"
}
]
},
"config": {
"view": {"stroke": "transparent"},
"font": "Segoe UI",
"axis": {
"ticks": false,
"grid": false,
"domain": false,
"title": "",
"labelColor": "#605E5C",
"labelFontSize": 12,
"titleFont": "wf_standard-font, helvetica, arial, sans-serif",
"titleColor": "#252423",
"titleFontSize": 16,
"titleFontWeight": "normal",
"labelPadding": 10
},
"tick": {
"stroke": "white",
"strokeWidth": 1,
"thickness": 3
},
"point": {
"filled": true,
"size": 50,
"opacity": 1
},
"style": {
"target": {"color": "#cd3838"},
"value_label": {
"color": "white",
"align": "left",
"dx": 5
}
}
},
"data": {"name": "dataset"},
"height": {"step": 30},
"encoding": {
"x": {
"type": "quantitative",
"axis": null
},
"y": {
"field": "__0__",
"sort": {
"field": "__1__",
"op": "sum",
"order": "descending"
}
}
},
"params": [
{
"name": "bar_color",
"value": "#aaa"
}
],
"transform": [
{
"calculate": "datum['__3__'] < 0",
"as": "gap_is_negative"
},
{
"calculate": "datum['gap_is_negative'] ? '#fff' : bar_color",
"as": "gap_color"
},
{
"calculate": "datum['gap_is_negative'] ? bar_color : '#fff'",
"as": "gap_color_inverse"
},
{
"calculate": "datum['__2__'] - (datum['__3__'] / 2)",
"as": "gap_label_x"
}
],
"layer": [
{
"description": "Main value bar",
"mark": {
"type": "bar",
"color": {"expr": "bar_color"},
"height": {"band": 0.8}
},
"encoding": {
"x": {"field": "__1__"}
}
},
{
"description": "Target tick",
"mark": {
"type": "tick",
"style": ["target"],
"height": {
"expr": "bandwidth('y')"
}
},
"encoding": {
"x": {"field": "__2__"}
}
},
{
"description": "Value label",
"mark": {
"type": "text",
"style": ["value_label"]
},
"encoding": {
"x": {"datum": 0},
"text": {
"field": "__1__",
"format": "#,###,",
"formatType": "pbiFormat"
}
}
},
{
"description": "Target label",
"layer": [
{
"description": "Target label foreground",
"mark": {
"type": "text",
"style": ["target"],
"align": {
"expr": "datum['gap_is_negative'] ? 'right' : 'left'"
},
"dx": {
"expr": "datum['gap_is_negative'] ? -10 : 10"
}
}
}
],
"encoding": {
"x": {"field": "__2__"},
"text": {
"field": "__2__",
"format": "#,###,",
"formatType": "pbiFormat"
}
}
},
{
"description": "Gap arrow main layer",
"encoding": {
"color": {
"value": {
"expr": "datum['gap_color']"
}
}
},
"layer": [
{
"description": "Gap arrow body",
"mark": {"type": "rule"},
"encoding": {
"x": {"field": "__1__"},
"x2": {"field": "__2__"}
}
},
{
"description": "Gap arrow head (left)",
"mark": {
"type": "point",
"shape": "triangle-left",
"xOffset": 3
},
"encoding": {
"x": {
"value": {
"expr": "scale('x', datum['gap_is_negative'] ? datum['__2__'] : datum['__1__'])"
}
}
}
},
{
"description": "Gap arrow head (right)",
"mark": {
"type": "point",
"shape": "triangle-right",
"xOffset": -3
},
"encoding": {
"x": {
"value": {
"expr": "scale('x', datum['gap_is_negative'] ? datum['__1__'] : datum['__2__'])"
}
}
}
}
]
},
{
"description": "Gap label main layer",
"encoding": {
"x": {"field": "gap_label_x"},
"text": {
"field": "__3__",
"format": "#,###,;#,##,",
"formatType": "pbiFormat"
}
},
"layer": [
{
"description": "Gap label halo (background)",
"mark": {
"type": "text",
"stroke": {
"expr": "datum['gap_color_inverse']"
},
"strokeWidth": 4
}
},
{
"description": "Gap label halo (background)",
"mark": {
"type": "text",
"color": {
"expr": "datum['gap_color']"
}
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment