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

x-axis time stamps configuration #303

Closed
dprokop opened this issue Sep 15, 2020 · 7 comments
Closed

x-axis time stamps configuration #303

dprokop opened this issue Sep 15, 2020 · 7 comments
Labels
question Further information is requested

Comments

@dprokop
Copy link

dprokop commented Sep 15, 2020

@leeoniya do you mind explaining what is the 3rd column in the values array when customizing time formatting as described here https://github.com/leeoniya/uPlot/tree/master/docs#axis--grid-opts ?

values: [
  [3600 * 24 * 365,    "{YYYY}",               7,   "{YYYY}"                    ],
  [3600 * 24 * 28,     "{MMM}",                7,   "{MMM}\n{YYYY}"             ],
  [3600 * 24,          "{M}/{D}",              7,   "{M}/{D}\n{YYYY}"           ],
  [3600,               "{h}{aa}",              4,   "{h}{aa}\n{M}/{D}"          ],
  [60,                 "{h}:{mm}{aa}",         4,   "{h}:{mm}{aa}\n{M}/{D}"     ],
  [1,                  "{h}:{mm}:{ss}{aa}",    4,   "{h}:{mm}:{ss}{aa}\n{M}/{D}"],
],

Also - what is the relation between values and the _timeAxisStamps?

I went through the code but there's plenty to digest there :)

@leeoniya
Copy link
Owner

leeoniya commented Sep 15, 2020

there's a recent breaking change coming in 1.2. see if the new format makes more sense:

#299

(read the comments above the config array in the code)

axis.values is a formatting function that accepts raw splits values and returns formatted tick labels. the default temporal axis formatter is able to accept a concise config array (_timeAxisStamps) which it pre-compiles.

@dprokop
Copy link
Author

dprokop commented Sep 15, 2020

Ah, I got super confused by the new format only because it's not released yet and I'm on 1.1.2:) I think it makes more sense than the current one - especially that the current one is cryptic - as I mentioned I don't know what 7 mean 4 mean in the 3rd column of the array.

The new one seems more readable, but still quite cryptic unless there is a documentation. For example with this line:

[s,   ss,  NLmdyy + " " + hmmaa,   _,  NLmd + " " + hmmaa,   _, NLhmmaa,  _, 1],

It will precompile the array in timeAxisStamps, but can you guide me or explain how is the format being picked when the axis is actually rendered? Looking at the config I just don't know what to expect to be rendered.

@leeoniya
Copy link
Owner

leeoniya commented Sep 15, 2020

the formatter goes through a selection process based on the axis splits spacing. this s line will get selected when the split spacing is >= 1s but less than the line above it (1min). that's what [0] is.

next, it will go through a selection process of whether to render the default tick format [1] or a more detailed rollover tick format [2]-[7] which will get appended (due to [8]) to the default tick format.

the first tick on the axis will always be a rollover tick because there's no prior context. the rest will track rollovers and modify which format to use dynamically based on what rolls over (year, month, day, etc...).

@dprokop
Copy link
Author

dprokop commented Sep 15, 2020

Ok, this makes sense, thank you. When do you plan 1.2 release?

@leeoniya
Copy link
Owner

there's nothing outstanding, so likely today or tomorrow.

@leeoniya leeoniya added the question Further information is requested label Sep 15, 2020
@leeoniya
Copy link
Owner

1.2.0 is published.

@dprokop
Copy link
Author

dprokop commented Sep 16, 2020

thank you @leeoniya, this is awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants