Skip to content

find reducer#1914

Merged
mbostock merged 6 commits into
mainfrom
mbostock/find
Nov 2, 2023
Merged

find reducer#1914
mbostock merged 6 commits into
mainfrom
mbostock/find

Conversation

@mbostock
Copy link
Copy Markdown
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
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