Skip to content

Add select transforms. #190

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 4 commits into from
Mar 4, 2021
Merged

Add select transforms. #190

merged 4 commits into from
Mar 4, 2021

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Mar 4, 2021

Introduces new transforms for pulling out individual values from the data, while being z- and facet-aware.

@mbostock mbostock requested a review from Fil March 4, 2021 19:14
@mbostock
Copy link
Member Author

mbostock commented Mar 4, 2021

I thought about naming these Plot.selectFirst, Plot.selectLast, Plot.selectMinX etc. Let me know if you prefer that additional verbosity.

@Fil
Copy link
Contributor

Fil commented Mar 4, 2021

I guess Plot.selectFirst etc. might help discoverability.

@mbostock
Copy link
Member Author

mbostock commented Mar 4, 2021

Okay, I adopted the longer names.

@mbostock
Copy link
Member Author

mbostock commented Mar 4, 2021

I’m feeling pretty good about this and will merge but let me know if you have any objections or suggestions! Thanks.

@mbostock mbostock merged commit 91afdcf into main Mar 4, 2021
@mbostock mbostock deleted the mbostock/select branch March 4, 2021 20:46
@Fil
Copy link
Contributor

Fil commented Mar 5, 2021

It's working great, and I like the way it anticipates multiple values. To test this out and make it more extensible I've tried to export Plot.select.

Then for example, I can select a few values to label a line chart:

    Plot.text(data, {
      transform: Plot.select(I => d3.range(50, I.length, 100), null, {}),
      x: "date",
      y: "value",
   })

the null and {} are unfortunate in this case (since I don't need any channel to work with), so maybe we could make the third argument optional.

I could also detect n local maxima, etc., by adding my own functions.

If we do export it, the function should probably be called differently, to avoid confusion with d3.select. Note that it's a filter (#138), in a somewhat raw form. A signature like Plot.selectFilter((I, V) => …, {...options, key: accessor}) might be easier to use than (I, V) => …, "key", options.

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