Skip to content

Instantly share code, notes, and snippets.

@RouxRC
Last active April 11, 2022 00:31
Show Gist options
  • Save RouxRC/85e41a34f8b2280ab30fd0095e82424f to your computer and use it in GitHub Desktop.
Save RouxRC/85e41a34f8b2280ab30fd0095e82424f to your computer and use it in GitHub Desktop.
Prez 2022
{
"$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/historique-voix.csv"
// "url": "https://raw.githubusercontent.com/RouxRC/prez-2022/main/historique-%25inscrits.csv"
"url": "https://raw.githubusercontent.com/RouxRC/prez-2022/main/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
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Jean-Luc MÉLENCHON"},
"stroke": {"value": "red"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Jean-Luc MÉLENCHON"},
"fill": {"value": "#fff"},
"stroke": {"value": "red"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Jean-Luc MÉLENCHON': datum['Jean-Luc MÉLENCHON']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Éric ZEMMOUR"},
"stroke": {"value": "brown"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Éric ZEMMOUR"},
"fill": {"value": "#fff"},
"stroke": {"value": "brown"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Éric ZEMMOUR': datum['Éric ZEMMOUR']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Valérie PÉCRESSE"},
"stroke": {"value": "steelblue"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Valérie PÉCRESSE"},
"fill": {"value": "#fff"},
"stroke": {"value": "steelblue"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Valérie PÉCRESSE': datum['Valérie PÉCRESSE']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Yannick JADOT"},
"stroke": {"value": "lightgreen"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Yannick JADOT"},
"fill": {"value": "#fff"},
"stroke": {"value": "lightgreen"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Yannick JADOT': datum['Yannick JADOT']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Jean LASSALLE"},
"stroke": {"value": "grey"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Jean LASSALLE"},
"fill": {"value": "#fff"},
"stroke": {"value": "grey"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Jean LASSALLE': datum['Jean LASSALLE']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Fabien ROUSSEL"},
"stroke": {"value": "red"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Fabien ROUSSEL"},
"fill": {"value": "#fff"},
"stroke": {"value": "red"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Fabien ROUSSEL': datum['Fabien ROUSSEL']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Nicolas DUPONT-AIGNAN"},
"stroke": {"value": "blue"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Nicolas DUPONT-AIGNAN"},
"fill": {"value": "#fff"},
"stroke": {"value": "blue"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Nicolas DUPONT-AIGNAN': datum['Nicolas DUPONT-AIGNAN']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Anne HIDALGO"},
"stroke": {"value": "pink"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Anne HIDALGO"},
"fill": {"value": "#fff"},
"stroke": {"value": "pink"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Anne HIDALGO': datum['Anne HIDALGO']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Philippe POUTOU"},
"stroke": {"value": "red"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Philippe POUTOU"},
"fill": {"value": "#fff"},
"stroke": {"value": "red"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Philippe POUTOU': datum['Philippe POUTOU']+'%'}"
}
}
},
"zindex": 2
},
{
"type": "line",
"aria": false,
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Nathalie ARTHAUD"},
"stroke": {"value": "red"},
"strokeWidth": {"value": 3}
}
}
},
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "Nathalie ARTHAUD"},
"fill": {"value": "#fff"},
"stroke": {"value": "red"},
"strokeWidth": {"value": 1},
"size": {"value": 49},
"tooltip": {
"signal": "{'Nathalie ARTHAUD': datum['Nathalie ARTHAUD']+'%'}"
}
}
},
"zindex": 2
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment