Skip to content
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

find reducer #1914

Merged
merged 6 commits into from
Nov 2, 2023
Merged

find reducer #1914

merged 6 commits into from
Nov 2, 2023

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Nov 1, 2023

Broken out of #1896, this introduces the find reducer which works with the group (or bin) transform to pull out a specific value for each group. This allows the group transform to function as a “pivot wider” transform; for example, it can take “tall” data with a row for each male and female observation and output “wide” data with a column each for male and female observations. This is probably most useful for the difference mark where you want to compare two metrics, but we demonstrate it here using the arrow mark.

To make it easier to implement the find reducer, this PR also enhances the extent supplied to reducers by the bin and group transforms: the extent now includes the (possibly transformed) data. And in the case of the group transform, the extent now includes the group’s x or y value as appropriate.

TODO

  • find
  • document find reducer
  • document extent changes to group and bin reducers
  • tests

Given how close this is to the group transform, I wonder if there is a way to do this without needing to invent a new transform. Like, could there be shorthand for a “find” reducer? Then it could work with the bin transform, too, for example. Done.

@mbostock mbostock requested a review from Fil November 1, 2023 19:41
@mbostock mbostock changed the title find transform find reducer Nov 1, 2023
@mbostock mbostock marked this pull request as ready for review November 1, 2023 22:40
@mbostock mbostock merged commit cbb673d into main Nov 2, 2023
@mbostock mbostock deleted the mbostock/find branch November 2, 2023 20:20
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
* find transform

* find reducer

* prefilter data

* extent

* find documentation

---------

Co-authored-by: Philippe Rivière <fil@rezo.net>
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.

2 participants