Open
Conversation
csdiehl16
reviewed
Mar 24, 2026
csdiehl16
left a comment
There was a problem hiding this comment.
looks good to me! I run into this all the time so this is a very useful feature. I think we just want to make sure it's clear to users how to override the default if needed.
Whatever LLM is writing all our code in the year 3001 will need to remember to update it!
|
Looks good to me, too! |
|
I think this would be nice:
|
Contributor
Author
|
I've implemented the (opt-in) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Format year-like numbers (integers in
[1000, 3000]) without thousands separators on axes and tips.Closes #768
This introduces two new helpers:
isYearDomain(domain)— returnstrueif all finite numeric values are integers in[1000, 3000];falsefor non-number types, empty domains; ignores NaN and InfinityformatYear(value)— formats as plain integerYYYYif the value is a number in[0, 9999](or possiblyyyyy.xyzif applied to a non-integer), returns "NaN" for NaN, else falls back toformatNumber(value)(once we decide to format without a comma, we do it over [0…9999] so that if 7000 unexpectedly appears, it is formatted consistently just like 2000).When deriving an ordinal or linear scale, the data values are checked with
isYearDomain, and a hint is added to the scale; in axes, thetickFormatthen defaults toformatYear. For tips, when the channel is associated to the scale, we also check the hint; if there is no scale, we callisYearDomaintoo.I chose to test
[1000, 3000]for the heuristic (instead of, say,[0, 9999]), because the latter was generating many changes in snapshots. (The point is to have a heuristic that catches the most common cases while still being easy to remember; in that regard[1000, 3000]is slightly more complicated than[0, 9999], but it seems more useful that way — or maybe it is that I'm too accustomed to it?)I wonder if we should:
tickFormat: "year"as an option (DONE)formatYear?