Created
February 9, 2021 21:38
-
-
Save n-dragon/52c90a6507b44462ee41a334ae28802a to your computer and use it in GitHub Desktop.
Vega spec from Tue Feb 09 2021
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega/v5.json", | |
"description": "A basic bar chart example, with value labels shown upon mouse hover.", | |
"width": 400, | |
"height": 200, | |
"padding": 5, | |
"title":"Infection par pays", | |
"data": [ | |
{ | |
"name": "covid", | |
"values": [ | |
{ | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Andorre", | |
"Infection": 10275, | |
"Deces": 106, | |
"Guerisons": 9610, | |
"TauxDeces": 1.03, | |
"TauxGuerison": 93.53, | |
"TauxInfection": 5.44 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Émirats Arabes Unis", | |
"Infection": 332603, | |
"Deces": 947, | |
"Guerisons": 313060, | |
"TauxDeces": 0.28, | |
"TauxGuerison": 94.12, | |
"TauxInfection": 5.59 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Afghanistan", | |
"Infection": 55384, | |
"Deces": 2414, | |
"Guerisons": 48109, | |
"TauxDeces": 4.36, | |
"TauxGuerison": 86.86, | |
"TauxInfection": 8.78 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Antigua-et-Barbuda", | |
"Infection": 316, | |
"Deces": 7, | |
"Guerisons": 189, | |
"TauxDeces": 2.22, | |
"TauxGuerison": 59.81, | |
"TauxInfection": 37.97 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Albanie", | |
"Infection": 87528, | |
"Deces": 1488, | |
"Guerisons": 52933, | |
"TauxDeces": 1.7, | |
"TauxGuerison": 60.48, | |
"TauxInfection": 37.82 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Arménie", | |
"Infection": 168300, | |
"Deces": 3126, | |
"Guerisons": 160169, | |
"TauxDeces": 1.86, | |
"TauxGuerison": 95.17, | |
"TauxInfection": 2.97 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Angola", | |
"Infection": 20112, | |
"Deces": 475, | |
"Guerisons": 18596, | |
"TauxDeces": 2.36, | |
"TauxGuerison": 92.46, | |
"TauxInfection": 5.18 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Argentine", | |
"Infection": 1985501, | |
"Deces": 49398, | |
"Guerisons": 1786178, | |
"TauxDeces": 2.49, | |
"TauxGuerison": 89.96, | |
"TauxInfection": 7.55 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Autriche", | |
"Infection": 426093, | |
"Deces": 8071, | |
"Guerisons": 404676, | |
"TauxDeces": 1.89, | |
"TauxGuerison": 94.97, | |
"TauxInfection": 3.13 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Australie", | |
"Infection": 28860, | |
"Deces": 909, | |
"Guerisons": 26098, | |
"TauxDeces": 3.15, | |
"TauxGuerison": 90.43, | |
"TauxInfection": 6.42 | |
}, { | |
"Date": "2021-02-09T00:00:00", | |
"Pays": "Azerbaïdjan", | |
"Infection": 231362, | |
"Deces": 3163, | |
"Guerisons": 225678, | |
"TauxDeces": 1.37, | |
"TauxGuerison": 97.54, | |
"TauxInfection": 1.09 | |
} | |
] | |
}, | |
{ | |
"name": "coco", | |
"source": "covid", | |
"transform": [ | |
{ | |
"type": "aggregate", | |
"groupby": [], | |
"ops": ["mean"], | |
"fields": [ | |
"Infection" | |
], | |
"as": [ | |
"Infection2" | |
] | |
} | |
] | |
} | |
], | |
"signals": [ | |
{ | |
"name": "select", "init": "1", | |
"on": [ | |
{ | |
"events": "click, [mousedown, window:mouseup] > mousemove", | |
"update": "invert('xscale', x())" | |
}, | |
{ | |
"events": "dblclick", | |
"update": "0" | |
} | |
] | |
}, | |
{ | |
"name":"selectz" | |
} | |
], | |
"scales": [ | |
{ | |
"name":"xscale", | |
"type": "band", | |
"domain": {"data": "covid", "field": "Pays"}, | |
"range":"width" | |
}, | |
{ | |
"name":"yscale", | |
"type": "linear", | |
"domain": {"data": "covid", "field": "Infection"}, | |
"range":"height" | |
}, | |
{ | |
"name":"tauxGuerison", | |
"type": "linear", | |
"domain": {"data": "covid", "field": "TauxGuerison"}, | |
"range":"height" | |
}, | |
{ | |
"name":"txInfectionColor", | |
"type": "linear", | |
"domain": {"data": "covid", "field": "TauxGuerison"}, | |
"range":{"scheme":"plasma"} | |
} | |
], | |
"axes": [ | |
{ "orient": "bottom", "scale": "xscale", "labelPadding": {"value": 50},"labelAngle": {"value": 90}}, | |
{ "orient": "right", "scale": "yscale", "offset":30,"title":"Infections"}, | |
{ "orient": "left", "scale": "tauxGuerison", "offset":30,"title":"taux guerison" | |
} | |
], | |
"marks": [ | |
{ | |
"type": "rect", | |
"from": {"data":"covid"}, | |
"encode": { | |
"enter":{ | |
"x":{"scale":"xscale","field":"Pays"}, | |
"width": {"scale": "xscale", "band": 0.8}, | |
"y":{"scale":"yscale","field":"Infection"}, | |
"y2": {"scale": "yscale", "value": 0} | |
} | |
} | |
}, | |
{ | |
"type": "symbol", | |
"from": {"data":"covid"}, | |
"encode": { | |
"enter":{ | |
"x":{"scale":"xscale","field":"Pays","offset":18}, | |
"y":{"scale":"tauxGuerison","field":"TauxGuerison"}, | |
"size":{"value":123} | |
},"update":{ | |
"shape":{"value": "square"}, | |
"fill":[{"scale":"txInfectionColor","field":"TauxGuerison"}] | |
}} | |
}, | |
{ | |
"type": "rule", | |
"interactive": false, | |
"encode": { | |
"update": { | |
"x": {"scale": "xscale", "signal": "select"}, | |
"y": {"value": 0}, | |
"y2": {"signal": "height"}, | |
"stroke": {"value": "green"} | |
} | |
} | |
}, | |
{ | |
"type": "text", | |
"interactive": false, | |
"encode": { | |
"enter": { | |
"baseline": {"value": "top"}, | |
"dx": {"value": 3}, | |
"y": {"value": 2} | |
}, | |
"update": { | |
"x": {"scale": "xscale", "signal": "select"}, | |
"text": {"signal": "scale('xscale',select)"}, | |
"fill": {"signal": "select ? '#000': 'transparent'"} | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment