Skip to content

Instantly share code, notes, and snippets.

@gsurrel
Created May 24, 2023 11:44
Show Gist options
  • Save gsurrel/c1ffc599f20e90f952939788336b47f2 to your computer and use it in GitHub Desktop.
Save gsurrel/c1ffc599f20e90f952939788336b47f2 to your computer and use it in GitHub Desktop.
Vega-Lite spec for GDPR fines across time
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"url": "https://www.enforcementtracker.com/data.json",
"format": {"type": "json", "property": "data"}
},
"params": [
{
"bind": "scales",
"select": {
"type": "interval",
"zoom": "wheel![!event.shiftKey]",
"encodings": ["x"]
},
"name": "zoomX"
},
{
"bind": "scales",
"select": {
"type": "interval",
"zoom": "wheel![event.shiftKey]",
"encodings": ["y"]
},
"name": "zoomY"
}
],
"transform": [
{"calculate": "toDate(datum[4])", "as": "Date"},
{"calculate": "toNumber(replace(datum[5], /,/g, ''))", "as": "amount"},
{"calculate": "datum[6]", "as": "place"},
{"calculate": "datum[7]", "as": "sector"},
{"calculate": "split(datum[8], 'Art.')", "as": "articles"},
{"calculate": "datum[9]", "as": "summary"},
{
"calculate": "'https://www.enforcementtracker.com/' + datum[1]",
"as": "href"
},
{"filter": "isValid(datum.amount) && datum.amount > 0"}
],
"title": {
"text": "GDPR fines",
"subtitle": [
"Data from enforcementtracker.com, provided by CMS Law.Tax, CC-BY-SA-NC",
"Mousewheel to zoom time, Shift+mousewheel to zoom the fine amount, click for details"
]
},
"width": "container",
"height": "container",
"autosize": {"resize": true},
"mark": {"type": "circle", "tooltip": {"content": "encoding"}},
"encoding": {
"x": {"field": "Date", "type": "temporal"},
"y": {
"field": "amount",
"type": "quantitative",
"scale": {"type": "log"},
"title": "Fine (€)"
},
"color": {"field": "summary"},
"href": {"field": "href"},
"detail": {"field": "place"}
},
"config": {
"background": "Canvas",
"view": {"stroke": "CanvasText", "opacity": 0.2},
"title": {"color": "CanvasText", "subtitleColor": "CanvasText"},
"style": {
"guide-label": {"fill": "CanvasText"},
"guide-title": {"fill": "CanvasText"}
},
"axis": {
"domainColor": "CanvasText",
"gridColor": "CanvasText",
"gridOpacity": 0.1,
"tickColor": "CanvasText",
"tickOpacity": 0.3
},
"legend": {
"labelLimit": 550,
"orient": "bottom",
"direction": "vertical",
"title": null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment