Skip to content

Add support for projections to the standalone Plot.scale function#2427

Open
Fil wants to merge 7 commits intomainfrom
fil/scale-projection
Open

Add support for projections to the standalone Plot.scale function#2427
Fil wants to merge 7 commits intomainfrom
fil/scale-projection

Conversation

@Fil
Copy link
Copy Markdown
Contributor

@Fil Fil commented Apr 13, 2026

e.g. Plot.scale({projection: {type: "mercator", width, domain: …}}).

When merged, we must add this to the changelog PR #2426:

The standalone [Plot.scale](https://observablehq.com/plot/features/scales#scale) function now also supports projections.

```js
const projection = Plot.scale({projection: {type: "mercator"}});
projection.apply([-1.55, 47.22]) // [316.7, 224.2]

const plot = Plot.plot({projection, marks: [Plot.sphere()]});
```

Fil added 2 commits April 13, 2026 17:26
_e.g._ Plot.scale({projection: {type: "mercator", width, domain: …}}).
@Fil Fil requested a review from mbostock April 13, 2026 15:46
Copy link
Copy Markdown
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.

As far as testing goes, I’m hoping that we can test this new implementation against the existing (more wasteful) one. This:

Plot.plot({projection: {type: "mercator"}}).scale("projection")

Should be the same as this:

Plot.scale({projection: {type: "mercator"}})

Fil and others added 5 commits April 13, 2026 23:54
Co-authored-by: Mike Bostock <mbostock@gmail.com>
note that the terse definitions here are for Plot.scale({projection}), and get overridden by more detailed definitions in Plot.plot()
@@ -1,3 +1,21 @@
/** Options for specifying the dimensions of a plot or standalone projection. */
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

note that the terse definitions here are in fact only for Plot.scale({projection}), and get overridden by more detailed definitions in Plot.plot(), i.e.

/**

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