Created
July 25, 2024 20:59
-
-
Save PBI-DataVizzle/e163c01b8c74745b5eb990ac07805b46 to your computer and use it in GitHub Desktop.
fold_donut
This file contains hidden or 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/v5.json", | |
"data": { | |
"values": [ | |
{"category": "A", "subcategory": "A1", "sales": 100}, | |
{"category": "A", "subcategory": "A2", "sales": 200}, | |
{"category": "B", "subcategory": "B1", "sales": 150}, | |
{"category": "B", "subcategory": "B2", "sales": 50} | |
] | |
}, | |
"transform": [ | |
{"fold": ["category", "subcategory"], "as": ["Type", "Name"]}, | |
{ | |
"calculate": "datum.Type === 'category' ? datum.sales : 0", | |
"as": "CategorySales" | |
}, | |
{ | |
"calculate": "datum.Type === 'subcategory' ? datum.sales : 0", | |
"as": "SubcategorySales" | |
} | |
], | |
"layer": [ | |
{ | |
"mark": {"type": "arc", "innerRadius": 80, "outerRadius": 100}, | |
"encoding": { | |
"theta": {"field": "CategorySales", "type": "quantitative"}, | |
"color": {"field": "Name", "type": "nominal"} | |
} | |
}, | |
{ | |
"mark": {"type": "arc", "innerRadius": 60, "outerRadius": 75}, | |
"encoding": { | |
"theta": {"field": "SubcategorySales", "type": "quantitative"}, | |
"color": {"field": "Name", "type": "nominal"} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment