Pie chart order #7903
-
|
Here's the pie chart example: How can I order the resulting sectors of the pie chart by value? I tried, among other things, putting |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
If you want the color scale to be ordered by value, you can use {
"data": {
"values": [
{"category": 1, "value": 4},
{"category": 2, "value": 6},
{"category": 3, "value": 10},
{"category": 4, "value": 3},
{"category": 5, "value": 7},
{"category": 6, "value": 8}
]
},
"mark": "arc",
"encoding": {
"theta": {"field": "value", "type": "quantitative"},
"color": {"field": "category", "type": "nominal", "sort": {"field": "value"}},
"order": {"field": "value"}
}
} |
Beta Was this translation helpful? Give feedback.
If you want the color scale to be ordered by value, you can use
"sort": {"field": "value"}within the color encoding. If you want the placement of the pie segments to be ordered by value, you can use"order": {"field": "value"}within the encoding. Putting both together:{ "data": { "values": [ {"category": 1, "value": 4}, {"category": 2, "value": 6}, {"category": 3, "value": 10}, {"category": 4, "value": 3}, {"category": 5, "value": 7}, {"category": 6, "value": 8} ] }, "mark": "arc", "encoding": { "theta": {"field": "value", "type": "quantitative"}, "color": {"field": "category", "type": "nominal", "sort": {"field": "value"}},