Skip to content

Instantly share code, notes, and snippets.

@PBI-DataVizzle
Created October 8, 2023 15:38
Show Gist options
  • Save PBI-DataVizzle/b150c5e43cd36fcc755cac3e88f50e4f to your computer and use it in GitHub Desktop.
Save PBI-DataVizzle/b150c5e43cd36fcc755cac3e88f50e4f to your computer and use it in GitHub Desktop.
Faceted Donut
{
"title": {
"text": "% Rating based on Category Type",
"anchor": "middle",
"color": "white",
"font": "helvatica",
"fontSize": 30
},
"data": {
"values": [
{
"Category": "Acousticness",
"Value": 1
},
{
"Category": "Danceability",
"Value": 79
},
{
"Category": "Energy",
"Value": 79
},
{
"Category": "Instrumentalness",
"Value": 0
},
{
"Category": "Liveness",
"Value": 10
},
{
"Category": "Speechiness",
"Value": 8
},
{
"Category": "Valence",
"Value": 68
}
]
},
"transform": [
{
"calculate": "100", "as": "_max"
},
{
"joinaggregate": [
{
"op": "mean",
"field": "_max",
"as": "Total"
}
]
}
],
"spacing": 0,
"facet": {
"column": {"field": "Category"}
},
"spec": {
"layer": [
{
"mark": {
"type": "text",
"fontSize": 20
},
"encoding": {
"text": {
"field": "Value",
"type": "nominal"
}
}
},
{
"mark": {
"type": "arc",
"innerRadius": 50,
"outerRadius": 30,
"color": "dimgrey"
},
"encoding": {
"theta": {
"field": "Total",
"aggregate": "sum",
"type": "quantitative"
}
}
},
{
"width": 160,
"height": 100,
"mark": {
"type": "arc",
"innerRadius": 50,
"outerRadius": 30,
"color": "limegreen"
},
"encoding": {
"theta": {
"field": "Value",
"aggregate": "sum",
"type": "quantitative"
}
}
}
],
"view": {"stroke": null}
}
}
@PBI-DataVizzle
Copy link
Author

facet donut

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment