observablehq / observablehq/plot

sort by channel not used to visualize?

Open
#867 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
HTML
Stars
5.4k
Forks
244
PR merge metrics
No merged PRs in 30d

Description

I have a dataset sorted by a column, lets say rate. I then create a stacked bar chart using a different column, lets say value.
I want a stacked bar chart on value but sorted by rate. Even though my data is already sorted by rate, when i do the following it orders the y domain alphabetically:

Plot.barX(data, { x: "value", y: "name", fill: "type" })

if I try to use sort: { y: "x", reverse: true, limit: 20 } I can't figure out how to get it to sort by my rate column instead.

I'm able to do a work around by explicitly setting the y domain to the sorted order of names I want, but it feels like i might be missing something?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Plot.barX example and the sort option described in the issue, then trace how the y domain is derived when x, y, and fill are supplied. Compare the current alphabetical ordering with the requested ordering by the separate rate column; done means a stacked value chart can use rate for y ordering without manually specifying the y domain.

Written by the indexing model from the issue text.

Assessment

Tech stack
d3, javascript
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.