-
Notifications
You must be signed in to change notification settings - Fork 173
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
year and integer type scales #1268
base: main
Are you sure you want to change the base?
Conversation
For axes, we also need to pass the following elements, which are not exposed by _plot_.scale("x"): - the scale's label - the underlying D3 scale’s tickFormat and tick functions - the range of the identity scale
…his cleans up the API
b13f8b9
to
a8a7ccc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we did this by introducing a new year scale type? Then we could change the inferScaleType function to choose year over linear if the data matches. We already have a bunch of inference in inferScaleType (rather than mixing inference into Scales), and using a new scale type gives an explicit way for the user to opt-in or opt-out of this behavior.
I guess we’d need year-point and year-band for the ordinal case? Or maybe a separate year option? I dunno. I’ll need to think about that one.
Can we do this without coupling it to #1265? I’m looking for smaller wins. |
Adds an integer flag on a scale when the associated channels are all integers, either because the interval option is integer, or because we checked a sample of 40 values in each channel.
This flag cannot be specified by the user (but they can use interval: 1), and is censored when the scale is exported.
When the axis text mark decides on its tickFormat, the heuristic is that if the scale is integer and the domain is covered by [1500...2200], it's probably best to default to "d" rather than formatDefault (for ordinal scales) or the linear scale’s default number format, since it's possible that the values are years.
Closes #768
(This is built on top of #1265 but the same logic could be built on the scale function.)
Related: #932