Skip to content

Instantly share code, notes, and snippets.

@mariobecerra
Created May 13, 2020 21:29
Show Gist options
  • Save mariobecerra/999dbf5d07bb0d82dd11413ea79da3a1 to your computer and use it in GitHub Desktop.
Save mariobecerra/999dbf5d07bb0d82dd11413ea79da3a1 to your computer and use it in GitHub Desktop.
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "Top 16 artists number of plays by gender",
"width": 700,
"height": 700,
"padding": 5,
"autosize": "none",
"data": [
{
"name": "tree",
"url": "https://gist.githubusercontent.com/saif-analyze/83de3a258ebb351e44bf5697657ed81e/raw/422585a10604cfee17d1b8b9dde9ebf9b884e481/circle_2.json",
"transform": [
{
"type": "stratify",
"key": "id",
"parentKey": "parent"
},
{
"type": "pack",
"field": "size",
"sort": {"field": "value"},
"size": [{"signal": "width"}, {"signal": "height"}]
}
]
}
],
"scales": [
{
"name": "color",
"type": "ordinal",
"domain": {"data": "tree", "field": "depth"},
"range": {"scheme": "tableau20"}
}
],
"marks": [
{
"type": "symbol",
"from": {"data": "tree"},
"encode": {
"enter": {
"shape": {"value": "circle"},
"fill": {"scale": "color", "field": "depth"},
"tooltip": {"signal": "datum.name + (datum.size ? ', ' + datum.size + ' plays' : '')"}
},
"update": {
"x": {"field": "x"},
"y": {"field": "y"},
"size": {"signal": "4 * datum.r * datum.r"},
"stroke": {"value": "white"},
"strokeWidth": {"value": 0.5}
},
"hover": {
"stroke": {"value": "red"},
"strokeWidth": {"value": 2}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment