Created
July 25, 2024 20:35
-
-
Save PBI-DataVizzle/fba4f57cc65bcba5a2c8f8209838249b to your computer and use it in GitHub Desktop.
hconcat_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": [ | |
{ | |
"joinaggregate": [{"op": "sum", "field": "sales", "as": "TotalSales"}], | |
"groupby": ["category"] | |
}, | |
{ | |
"joinaggregate": [ | |
{"op": "sum", "field": "sales", "as": "SubcategoryTotal"} | |
], | |
"groupby": ["subcategory"] | |
} | |
], | |
"hconcat": [ | |
{ | |
"transform": [ | |
{ | |
"aggregate": [ | |
{"op": "sum", "field": "TotalSales", "as": "CategoryTotalSales"} | |
], | |
"groupby": ["category"] | |
} | |
], | |
"mark": {"type": "arc", "innerRadius": 80, "outerRadius": 100}, | |
"encoding": { | |
"theta": {"field": "CategoryTotalSales", "type": "quantitative"}, | |
"color": {"field": "category", "type": "nominal"} | |
} | |
}, | |
{ | |
"transform": [ | |
{ | |
"aggregate": [ | |
{"op": "sum", "field": "sales", "as": "SubcategoryTotalSales"} | |
], | |
"groupby": ["subcategory"] | |
} | |
], | |
"mark": {"type": "arc", "innerRadius": 40, "outerRadius": 80}, | |
"encoding": { | |
"theta": {"field": "SubcategoryTotalSales", "type": "quantitative"}, | |
"color": {"field": "subcategory", "type": "nominal"} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment