Skip to content

Pie chart order #7903

Answered by jakevdp
hoclun-rigsep asked this question in Q&A
Discussion options

You must be logged in to vote

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"}},
    

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by domoritz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants