Skip to content
Discussion options

You must be logged in to vote

If you have an explicit order, you set the domain of the y-scale.

Plot.plot({
  color: {
    scheme: "Tableau10"
  },
  y: {
    domain: order
  },
  marks: [
    Plot.barX(
      data,
      Plot.stackX({
        x: "value",
        y: "city",
        fill: "group"
      })
    ),
    Plot.text(data, {
      x: "value",
      y: "city",
      text: (d) => d.value.toLocaleString("ru"),
      fill: "white"
    })
  ]
})

The sort option is for when you need to derive the domain from data. If you’ve already derived the domain yourself, you just set it directly.

If you wanted to derive the order inline, in this case you could use the data as the input channel to the sort option like so:

Plot.p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@quillcraft
Comment options

Answer selected by quillcraft
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