Skip to content

sort aliases #770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2022
Merged

sort aliases #770

merged 2 commits into from
Feb 20, 2022

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Feb 19, 2022

Fixes #769. Introduces a concept of channel aliases and derived channels when sorting. For example, if you request to sort on “y”, but there is no y channel, it will fallback to y2. The new “dx” and “dy” refer to implicitly derived channels representing |x2 - x1| and |y2 - y1| respectively. For these channels, reverse defaults to true (since they typically represent a length encoding rather than a position encoding).

Screen Shot 2022-02-19 at 4 07 52 PM

Plot.plot({
  x: {
    tickFormat: "d",
    label: null
  },
  y: {
    label: "↑ Annual production (quads)"
  },
  color: {
    tickFormat: t => types.get(t),
    legend: true
  },
  marks: [
    Plot.rectY(energy, {x: "Year", interval: 1, y: "Value", fill: "Description", sort: {color: "dy"}}),
    Plot.ruleY([0])
  ]
})

@mbostock mbostock requested a review from Fil February 19, 2022 23:11
@mbostock mbostock force-pushed the mbostock/sort-aliases branch 3 times, most recently from d59577d to fc4337f Compare February 20, 2022 00:10
@mbostock mbostock force-pushed the mbostock/sort-aliases branch from fc4337f to 325779e Compare February 20, 2022 00:13
Copy link
Contributor

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Although I think it would be easier to memorize and explain if it were called width and height rather than dx and dy?

@mbostock mbostock merged commit ed0848d into main Feb 20, 2022
@mbostock mbostock deleted the mbostock/sort-aliases branch February 20, 2022 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Easier sorting of bins by weight?
2 participants