observablehq / observablehq/plot
Format the result of a built-in reducer
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 5.4k
- Forks
- 244
- PR merge metrics
- No merged PRs in 30d
Description
When using a built-in reducer that returns a number such as sum or proportion, sometimes you want to apply a number formatter for better readability. You can do that by re-implementing the reducer in user code:
But it’d be nice if there were either a hook to wrap the built-in reducer (e.g., a format option as an output channel for the group and bin transform that applies to the text and title channels?) or if we exposed the internal implementations so that you can more easily wrap them.
Also, sometimes you don’t just want to format the output of a single reducer; you might want to run multiple reducers and combine them into the tooltip or text.
Previously #655.
Ref. https://talk.observablehq.com/t/observable-plot-formatting-group-transform-proportion-text/7409/2
Ref. https://talk.observablehq.com/t/getting-values-for-proportion-reducers-in-plot/6040/2
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 with src/transforms/group.js at lines 388–392, where the linked built-in reducer implementations are defined. Read the discussion in #655 and the two referenced Observable forum threads to understand the proposed API choices. Done means establishing a clear way to format reducer output and, if supported, combine multiple reducer results for text or tooltips.
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
- Needs clarification
- Newbie friendliness
- 25/100