Last active
November 13, 2018 20:16
-
-
Save Ajax12345/b76f994768a555440214fa0ff97bb05f to your computer and use it in GitHub Desktop.
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-lite/v3.json", | |
"description": "The total number of votes each candidate got in the 2016 presidential primary.", | |
"width": 600, | |
"height": 600, | |
"padding": 5, | |
"autosize": "none", | |
"data": { | |
"values": [ | |
{"color": "red", "Candidate": "Ben Carson", "Total Votes": 564553}, | |
{"color": "red", "Candidate": "Carly Fiorina", "Total Votes": 15191}, | |
{"color": "red", "Candidate": "Chris Christie", "Total Votes": 24353}, | |
{"color": "red", "Candidate": "Donald Trump", "Total Votes": 13302541}, | |
{"color": "red", "Candidate": "Jeb Bush", "Total Votes": 94411}, | |
{"color": "red", "Candidate": "John Kasich", "Total Votes": 4159949}, | |
{"color": "red", "Candidate": "Marco Rubio", "Total Votes": 3321076}, | |
{"color": "red", "Candidate": "Ted Cruz", "Total Votes": 7603006}, | |
{"color": "red", "Candidate": "Mike Huckabee", "Total Votes": 3345}, | |
{"color": "red", "Candidate": "Rand Paul", "Total Votes": 8497}, | |
{"color": "blue", "Candidate": "Hillary Clinton", "Total Votes": 15692452}, | |
{"color": "blue", "Candidate": "Bernie Sanders", "Total Votes": 11959102}, | |
{"color": "blue", "Candidate": "O'Malley", "Total Votes": 752} | |
] | |
}, | |
"transform": [ | |
{"calculate" : "toString('black')", "as": "color2"} | |
], | |
"encoding": { | |
"y": { | |
"field": "Candidate", | |
"type": "ordinal" | |
}, | |
"x": { | |
"field": "Total Votes", | |
"type": "quantitative" | |
}, | |
"color": { | |
"field": "color", | |
"type": "nominal", | |
"scale": null | |
} | |
}, | |
"layer": [ | |
{ | |
"mark": "bar" | |
}, | |
{ | |
"mark": { | |
"type": "text", | |
"align": "left", | |
"baseline": "middle", | |
"dx": 7 | |
}, | |
"encoding": { | |
"text": { | |
"field": "Total Votes", | |
"type": "quantitative" | |
}, | |
"color": { | |
"field" : "color2", | |
"type": "ordinal", | |
"scale": null | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment