Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use midpoint of range with collapsed domains? #117

Closed
mbostock opened this issue Sep 28, 2017 · 1 comment
Closed

Use midpoint of range with collapsed domains? #117

mbostock opened this issue Sep 28, 2017 · 1 comment

Comments

@mbostock
Copy link
Member

mbostock commented Sep 28, 2017

Extracted from #113: when a scale has a collapsed domain (or domain segment), we currently map the value to the start of the corresponding range (or range segment). For example:

var x = d3.scaleLinear().domain([4, 4]).range([0, 10]);

x(4); // 0

This is of course arbitrary; it should be valid to return any value in the corresponding range. The current implementation uses constant(0) in this case, but it should be a matter of using constant(0.5) instead:

export function deinterpolateLinear(a, b) {
return (b -= (a = +a))
? function(x) { return (x - a) / b; }
: constant(b);
}

Though, we’ll now have to check explicitly for isNaN(b).

@mbostock
Copy link
Member Author

Fixed in #156.

@mbostock mbostock mentioned this issue Jan 26, 2019
Merged
13 tasks
Fil added a commit to romsson/d3-gridding that referenced this issue Dec 3, 2019
See #29

Unfortunately we can't build with d3-scale > 2.1.2, there is an incompatibility with https://github.com/d3/d3-scale/releases/tag/v2.2.0 — probably due to d3/d3-scale#117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant