-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Domain nicing may break when zero: true #2634
Comments
The issue seems to be that linear scales nice domains differently when the first value is small or not. $ d3.scaleLinear().domain([60,210]).nice(2).domain()
[0,400]
$ d3.scaleLinear().domain([70,210]).nice(2).domain()
[0,300] I would expect that both domains produce the same niced domain as they are both contained within the niced domain of the other. |
The issue with the code above is that ticks generated from the niced domain do not surround the domain anymore. $ d3
.scaleLinear()
.domain([70, 210])
.nice(2)
.ticks(2)
[0,200] Should I expect this to work or am I misunderstanding what nicing is supposed to do? The d3 docs say about I filed this as d3/d3-scale#209. |
The Scale transform in vega-encode is the primary contact point, where we invoke d3’s nice function. This looks like a potential d3-scale issue, so that’s the right place to file. What we do in Vega is pre-process the domain (ensuring zero as needed, any domain padding, etc) then invoke nice if the scale definition specifies it. I wonder if the specific tick count argument (2) drives the behavior here. |
Confirmed bug and we have a fix in d3/d3-scale#210. I'll leave this issue open so we make sure to update Vega once the fix is out. |
Notice how in the example below, the domain is not nice when
zero: true
.Open the Chart in the Vega Editor
The text was updated successfully, but these errors were encountered: