LDub
2 years agoHelper I
Deneb Donut
I am trying to make a Deneb donut so that I can use patterning. Modifying the EnterpriseDNA DonutKPI JSON, I've been able to add a slice for one Category, but I can't for the life of me figure out how to add multiple slices.
This is the JSON for this one slice:
{
"description": "Donut KPI Chart",
"data": {"name": "dataset"},
"transform": [
{
"calculate": "2*3.14*datum['Export Sales Value']/100",
"as": "Ring1_Theta2"
},
{
"calculate": "2*3.14*datum['Distributor Sales Value']/100",
"as": "Ring2_Theta2"
},
{
"calculate": "datum['Export Sales Value'] + '%'",
"as": "Ring1_Percent_Label"
},
{
"calculate": "datum.Ring1_Theta2 + datum.Ring2_Theta2",
"as": "theta2"
}
],
"params": [
{"name": "ring_max", "value": 100},
{"name": "ring_width", "value": 20},
{"name": "ring_gap", "value": 5},
{
"name": "ring0_color",
"value": "#FFFFFF"
},
{
"name": "ring1_color",
"value": "#0F4C81" //navy
},
{
"name": "ring2_color",
"value": "#E3F3FB" //lt blue
},
{
"name": "label_color",
"value": "#000000"
},
{
"name": "ring_background_opacity",
"value": 0.3
},
{
"name": "ring0_percent",
"value": 100
},
{
"name": "ring0_outer",
"expr": "ring_max+2"
},
{
"name": "ring0_inner",
"expr": "ring_max+1"
},
{
"name": "ring1_outer",
"expr": "ring0_inner-ring_gap"
},
{
"name": "ring1_inner",
"expr": "ring1_outer-ring_width"
},
{
"name": "ring1_middle",
"expr": "(ring1_outer+ring1_inner)/2"
}
],
"layer": [
{
"description": "Background",
"mark": {
"type": "arc",
"outerRadius": 100,
"innerRadius": 50
},
"encoding": {
"color": {
"value": "#002F6C"
}
}
},
{
"description": "ExportArc",
"mark": {
"type": "arc",
"outerRadius": 100,
"innerRadius": 50
},
"encoding": {
"theta": {
"value": 0
},
"theta2": {
"field": "Ring1_Theta2",
"type": "quantitative"
},
"color": {
"value": "#666666"
}
}
}
]
}
- Anonymous2 years ago
Hi LDub ,
Based on your description, you can try the following code{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": { "values": [ {"Name": "Measure 1", "Value": "1"}, {"Name": "Measure 2", "Value": "2"}, {"Name": "C", "Value": 3}, {"Name": "D", "Value": 4} ] }, "mark": {"type": "arc", "innerRadius": 50}, "encoding": { "theta": {"field": "Value", "type": "quantitative"}, "color": {"field": "Name", "type": "nominal"} } }You can change the value in the value according to your data, you need to make sure that the value in the value in the visualization of the filed to be able to fetch.
Best regards,
Albert HeIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly