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

d3.extentDiverging? #132

Closed
mbostock opened this issue Dec 3, 2019 · 2 comments
Closed

d3.extentDiverging? #132

mbostock opened this issue Dec 3, 2019 · 2 comments

Comments

@mbostock
Copy link
Member

mbostock commented Dec 3, 2019

It’d be nice to have a variant of d3.extent that returns a three-element array with zero in the middle for use with d3.scaleDiverging.

function extentDiverging() {
  const [x0, x1] = extent.apply(this, arguments);
  return [Math.min(0, x0), 0, Math.max(0, x1)];
}
@mbostock mbostock changed the title d3.extentDiverging d3.extentDiverging? Dec 3, 2019
Fil added a commit to d3/d3-scale that referenced this issue Jun 24, 2020
…extent and a pivot (default: 0)

examples:
-  d3.scaleDiverging().domain([-10, 145]).domain() // [-10, 0, 145]
-  d3.scaleDiverging().domain([89, 145], 100).domain() // [89, 100, 145]
-  d3.scaleDiverging().domain([112, 145], 100).domain() // [100, 100, 145]
-  d3.scaleDiverging().domain([-112, -145], -100).domain() // [-100, -100, -145]

solves d3/d3-array#132
@Fil
Copy link
Member

Fil commented Jun 24, 2020

It was a bit odd that the pivot for extentDiverging would be 0, while it is 0.5 for the default domain of scaleDiverging.

Also, this might be served better by a more intelligent scaleDiverging.domain based on domain.length:

ie d3.scaleDiverging().domain([x0, x1], pivot=0) would be similar to .domain([max(pivot,x0), pivot, min(pivot,x1)])

see d3/d3-scale#215 for a proposal

@mbostock
Copy link
Member Author

mbostock commented Apr 1, 2022

Not planning on doing this.

@mbostock mbostock closed this as completed Apr 1, 2022
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

2 participants