Skip to content

Comments

implicit zero#2332

Draft
mbostock wants to merge 4 commits intomainfrom
mbostock/implicit-zero
Draft

implicit zero#2332
mbostock wants to merge 4 commits intomainfrom
mbostock/implicit-zero

Conversation

@mbostock
Copy link
Member

Fixes #2331. Breaks a bunch of tests, of course. And should probably only apply to positional scales, not to (e.g.) color? And having an implicit rule would also be nice. Is this too opinionated?

@mbostock mbostock requested a review from Fil June 19, 2025 02:38
@Fil
Copy link
Contributor

Fil commented Jun 19, 2025

I don't mind it being applied to color as well, in the linear case. But it's probably less important.

Adding a default rule seems a tad too opinionated. The new visible tick at 0 is enough to ground the chart.

Copy link
Contributor

@Fil Fil left a comment

Choose a reason for hiding this comment

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

When the domain is explicit and zero is implicit, we should not modify the domain.

For example:

Plot.plot({x: { domain: [1, 16] }})

should result in a domain of [1, 16], not [0, 16]. However we want [0, 16] when we ask for

Plot.plot({x: { domain: [1, 16], zero: true }})

When the two statements are present, zero has priority. It's useful in some cases.

However when zero is implicit, the domain statement should be respected, if present, and the implicit zero should only be applied if the domain is derived from the data.

I've pushed new code to that effect (and double-checked all tests).

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.

Include zero in the domain of default positional scales if it's "almost" there?

2 participants