observablehq / observablehq/plot

The normalize transform should mirror the map transform more closely

Open
#1,376 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
HTML
Stars
5.4k
Forks
244
PR merge metrics
No merged PRs in 30d

Description

The normalizeX and normalizeY transforms mirror mapX and mapY, the only difference being that you specify a shorthand basis instead of a generic map. But the normalize method isn’t a transform, like the map transform: it returns a map implementation. And hence you have to use it in conjunction with the map transform like so:

Plot.map({title: Plot.normalize("first")}, {x: "Date", title: "Close", stroke: "Symbol"})

It would be shorter and more consistent to have normalize be a transform just like map, where you declare outputs and inputs:

Plot.normalize({title: "first"}, {x: "Date", title: "Close", stroke: "Symbol"})

If desired, we could retain the existing normalize method as Plot.normalizer or some such. (We might offer a similar Plot.reducer for reducer implementations in the future.) Possibly we could change Plot.normalize while retaining backwards compatibility by checking what you pass in, but it’s a little dicey. 🙂

Inspired by #1354.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the normalizeX and normalizeY transforms with mapX and mapY, then inspect the normalize method and the transform API. Determine how Plot.normalize should accept declared outputs and inputs, including whether the existing method remains backward-compatible. Done means the proposed transform usage works consistently with map and the relevant existing behavior is covered.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.