Skip to content

Conversation

@Fil
Copy link
Contributor

@Fil Fil commented Jan 7, 2022

demo: https://observablehq.com/@observablehq/plot-select-generalize-656

closes #515

select a sample:
Capture d’écran 2022-01-11 à 11 31 12

select min and max of a color:
Capture d’écran 2022-01-11 à 11 31 30

@Fil Fil requested a review from mbostock January 7, 2022 07:58
Copy link
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

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

How about this?

Plot.select({x: "min"}, options)

And we could throw an error if you pass an object with more than one (or less than one) key as the first argument.

@Fil Fil requested a review from mbostock January 11, 2022 10:29
@mbostock
Copy link
Member

On the topic of having a selector interface {select(I, V)} instead of just a function(I, V), so that we could potentially have a more convenient shorthand form for functions, I couldn’t think of a better shorthand for functions in this case, so I’m going to punt on that even though it’s a little different than what we did for reduce and map. Unlike, say, the filter transform, the select transform operates on a group of data at a time, so we need a way to identify a subset of that data, and a subset of the index feels like the most natural form for that.

@mbostock mbostock merged commit c77b252 into main Jan 16, 2022
@mbostock mbostock deleted the fil/select-any branch January 16, 2022 17:58
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.

Generalize the select transform

3 participants