Last active
April 29, 2020 21:20
-
-
Save Finterly/067e28a31a23e40f9c0c4af7ceace968 to your computer and use it in GitHub Desktop.
UShatecrime Wordcloud
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 word cloud visualization depicting Vega research paper abstracts.", | |
"width": 800, | |
"height": 400, | |
"padding": 0, | |
"data": [ | |
{ | |
"name": "table", | |
"url": "https://raw.githubusercontent.com/Finterly/Datasets_to_play_with/master/wordscloud", | |
"transform": [ | |
{ | |
"type": "formula", | |
"as": "angle", | |
"expr": "[-45, 0, 45][~~(random() * 3)]" | |
}, | |
{ | |
"type": "formula", | |
"as": "weight", | |
"expr": "if(datum.text=='VANDALISM', 350, 100)" | |
} | |
] | |
} | |
], | |
"scales": [ | |
{ | |
"name": "color", | |
"type": "ordinal", | |
"domain": { | |
"data": "table", | |
"field": "text" | |
}, | |
"range": [ | |
"#EE8D12", | |
"#93959", | |
"#5B20EB" | |
] | |
} | |
], | |
"marks": [ | |
{ | |
"type": "text", | |
"from": { | |
"data": "table" | |
}, | |
"encode": { | |
"enter": { | |
"text": { | |
"field": "text" | |
}, | |
"align": { | |
"value": "center" | |
}, | |
"baseline": { | |
"value": "alphabetic" | |
}, | |
"fill": { | |
"scale": "color", | |
"field": "text" | |
} | |
}, | |
"update": { | |
"fillOpacity": { | |
"value": 1 | |
} | |
}, | |
"hover": { | |
"fillOpacity": { | |
"value": 0.5 | |
} | |
} | |
}, | |
"transform": [ | |
{ | |
"type": "wordcloud", | |
"size": [ | |
800, | |
400 | |
], | |
"text": { | |
"field": "text" | |
}, | |
"rotate": { | |
"field": "datum.angle" | |
}, | |
"font": "Helvetica Neue, Arial", | |
"fontSize": { | |
"field": "datum.count" | |
}, | |
"fontWeight": { | |
"field": "datum.weight" | |
}, | |
"fontSizeRange": [ | |
12, | |
56 | |
], | |
"padding": 2 | |
} | |
] | |
} | |
], | |
"config": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment