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

scaleLinear returns invalid value for domain = [0, 0] #1070

Closed
zouxuoz opened this issue Feb 17, 2021 · 1 comment
Closed

scaleLinear returns invalid value for domain = [0, 0] #1070

zouxuoz opened this issue Feb 17, 2021 · 1 comment

Comments

@zouxuoz
Copy link

zouxuoz commented Feb 17, 2021

Looks like scaleLinear returns invalid value for domain = [0, 0]

Use case: when all values on the chart equals 0

Current behaviour:

scaleLinear({ range: [100, 0], domain: [0, 0] })(0); // returns 50

image

Expected behaviour:

scaleLinear({ range: [100, 0], domain: [0, 0] })(0); // returns 0
@williaster
Copy link
Collaborator

williaster commented Feb 17, 2021

Hey @zouxuoz 👋 thanks for checking out visx. This actually isn't a visx issue, and it is intentional behavior from the underlying d3-scale for "collapsed domains" (where start === end).

This is similar to visx issue #473 with a suggested workaround, and ultimately you can see the d3-scale issue/fix here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants