Skip to content

Instantly share code, notes, and snippets.

@RouxRC
Created April 24, 2022 19:59
Show Gist options
  • Save RouxRC/6ff13d2e2477b121c0ad1103ba024f3e to your computer and use it in GitHub Desktop.
Save RouxRC/6ff13d2e2477b121c0ad1103ba024f3e to your computer and use it in GitHub Desktop.
Prez 2022 - tour 2
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic line chart example.",
"width": 1000,
"height": 700,
"padding": 5,
"data": [
{
"name": "table",
"format": {"type": "csv", "parse": {"datetime": "date"}},
"url": "https://raw.githubusercontent.com/RouxRC/prez-2022/main/tour-2/historique-%25exprimes.csv"
}
],
"scales": [
{
"name": "x",
"type": "time",
"range": "width",
"domain": {"data": "table", "field": "datetime"}
},
{
"name": "y",
"type": "linear",
"range": "height",
"nice": true,
"zero": true,
"domain": {"data": "table", "field": "Emmanuel MACRON"}
}
],
"axes": [
{
"orient": "bottom",
"scale": "x",
"format": "%H:%M",
"labelPadding": 10,
"zindex": 1
},
{"orient": "left", "scale": "y"}
],
"marks": [
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Emmanuel MACRON"},
"stroke": {"value": "orange"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Emmanuel MACRON"},
"fill": {"value": "#fff"},
"stroke": {"value": "orange"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Emmanuel MACRON': datum['Emmanuel MACRON']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Marine LE PEN"},
"stroke": {"value": "darkblue"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Marine LE PEN"},
"fill": {"value": "#fff"},
"stroke": {"value": "darkblue"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {"signal": "{'Marine LE PEN': datum['Marine LE PEN']+'%'}"}
}
},
"zindex": 2
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment