observablehq / observablehq/plot
Distinguish select from selectAll
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 5.4k
- Forks
- 244
- PR merge metrics
- No merged PRs in 30d
Description
The select transform, when you provide a function, is really “selectAll”: it can select multiple elements in each series. Whereas all the built-in named selectors only select a single element. This makes it a little confusing. For example, using a built-in selector, you’d say:
Plot.selectFirst({x: "Date", y: "Close"})
Or equivalently:
Plot.select("first", {x: "Date", y: "Close"})
But if you implemented this as a function with the obvious interpretation, it will crash!
Plot.select((I) => I[0], {x: "Date", y: "Close"}) // 💥
You need to return a single-element array instead:
Plot.select((I) => [I[0]], {x: "Date", y: "Close"})
It’d be nice if we the select transform’s selector expected you to return a single index, and we provided a separate selectAll transform for selecting multiple things (within each series). Then the above would work, and if you want to select multiple values, you can use selectAll:
Plot.selectAll((I) => [I[0], I[I.length - 1]], {x: "Date", y: "Close"})
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the select transform API described in the issue and compare the built-in selectFirst/select behavior with function selectors. Check how selectors are interpreted per series, then verify that single-index select and multi-index selectAll match the examples and intended distinction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100