-
Notifications
You must be signed in to change notification settings - Fork 530
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
Addition of support to plot time along the x-axis #34
Comments
Other people have asked for time-formatted x-axes, so I think it's probably a feature that could be useful and something we can start looking into. I see two paths forward:
Either way, we will need a more sophisticated grid division/subdivision approach that only subdivides if labels do not overlap, or hides labels when they do overlap. This should be our first focus. |
Also, we might keep the gridlines constant for a frame for better visibility and divide a given time into a specific number of slots and mark their labels to help make it dynamic. |
Hi @epezent . Hi have added support for time axis with formatting based on current data range . Any suggestion on handling nanoseconds timestamps as currently in the api data is passed in float and all calculations are done in floating point . I end up losing precision for timestamps . I was thinking of templatizing the data type but that would be a major change across the library . |
@Prinkesh , this looks awesome!! Thanks for taking the lead on this. I agree, templatizing the data type might be nasty and would necessitate bringing a lot of stuff into the header. There's been some discussion on moving to I can look into this today, if you can put nanoseconds on hold. I'll report back when the change is made. In the meantime, I have some suggestions:
|
right now i detect the range of data and format the labels as follows
The table is in precedence order . Ex num_months > divisions than 1st row format is applied so on . Further i am adding prefix on Left most part of graph (prefix format would be the upper precedence for the data i.e if data falls in microsec range than prefix will fall in millisecs range])
even double will loose precision . At max microseconds could be supported . else uint64_t is needed . Which requires a lot of change after introducing that type of y and x axis would be different
No such reason i was experimenting with nanosecond data thats why its stretched. But number of subdivisions should be less from my experimentation in small window size
Agree with this . We can pick the first tick as a multiple of some number than rest can be calculated easily . |
How likely is it that someone would want to have a plot is zoomable from years/months to nanoseconds? Seems like an extreme use case to me. What we might need to do, is have multiple time formatting options. For example:
|
That is true .. This is for the purpose that user doesn't need to specify the data format . Rather they will just specify that x axis is time . I think we can also solve nanosecond issue but having an time offset .. So if someone is viewing. nanosecond level data . We might give an offset of start time and other data would be relative to that . Only formatter will use the offset time to calculate the formatting value . |
Even then, how is data interpreted? Always as seconds I presume? I do see you point though. It would be nice if it just magically worked without setting different flags. One thing I want to avoid is changing the plotting API function signature(s) or adding new signatures just for time formatted plots. I'm not sure if your offset approach would be possible then. |
I was thinking of milliseconds as most use case would be for signal processing / latency analysis / mainly high frequency data . If someone wanted to do analysis on yearly /monthly / daily data / low frequency of data better choice would web based plotting libs .
We could add something like this probably
and maintain this base_value while calculating tick_markers ? |
Hi @epezent , Will you be adding support for |
Yes I’m working on it. And yes it will require a new vec2 |
I may not be able to finish this today. Perhaps tomorrow. Sorry for the delay. |
@Prinkesh , you can give double precision a try on the double branch. Also, can you please provide input on #36 |
@Prinkesh, any updates on your PR? If this isn't something you can continue working on, I can try myself. Let me know. |
Will update it by tomorrow .
…On Fri, Jun 5, 2020, 10:47 PM Evan Pezent ***@***.***> wrote:
@Prinkesh <https://github.com/Prinkesh>, any updates on your PR? If this
isn't something you can continue working on, I can try myself. Let me know.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#34 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABLDNUQDQROB7GDSCK3IZ4TRVESBTANCNFSM4NAELKYQ>
.
|
This is awesome. Can't wait to try it. |
To give an update on this, @Prinkesh's PR was obliterated by the recent refactors. I've pieced it back together for the most part on the |
Good to know this is in the works. Our users have been requesting this features in our wrapping. |
I'm happy to share a long overdue update for this! It's been rather challenging to get just right, but I nearly have this working to the level of quality I hope to achieve. Check it out! A few details:
I still need to do more testing, bug fixing, and code cleanup. But if you are interested, you can check out my progress on the Also, thank you @Prinkesh for your initial attempt. I used bits and pieces of your code in my implementation. |
Awesome! I will be checking this out later tonight or tomorrow. I have Linux and MacOS machines setup already so I will let you know how that goes. Great work, man! |
the one rough spot in uPlot's config format & impl - and this is a balance between pragmatism and perfection - is that it only tracks 2 levels of context, which means that when you're looking at hour or minute-level resolutions, each rollover renders the full context (year, month, day) even when they remain unchanged, which is often more than necessary: leeoniya/uPlot#284 (comment) |
yep, it's not intentional, per se. uPlot's config array [1] wouldn't be that difficult to expand to track every level of context, but it would get quite large without some mechanism/abstraction for defining similar behavior for swaths of contexts. i haven't thought of what that may look like and still remain cognitively grokkable. |
@leeoniya's uPlot OHLC demo recreated in full now with time formatted axes. The only difference seems to be that uPlot can skip Saturday/Sunday. I'm not too worried about implementing that right now. Still a few things to add and tidy up, but I'm very happy with where it's at so far. |
nice :) you should draw the hover bar it looks like you're doing "major" ticks at month boundaries? which is a bit different than what uPlot does (ordinal/even spacing). this causes your version to have denser labels near the major ticks. (e.g. 3/29 and 4/1). it's probably the right trade-off in most cases. uPlot has no concept of major/minor ticks currently. btw, i think i have context tracking config array figured out. still finishing it up but it'll land soon if it works out. |
That's correct. My implementation sort of works like this:
My first naive approach simply subdivided major sections n times, evenly, to get the minor ticks, but what ended up happening is that I'd have a label that wasn't exactly what it said it should be, e.g. "3/29" might not be exactly midnight. Decided I'd rather have the labels be exact than evenly spaced. For days/months, it's noticeable like you say toward the end of the month when it's on a 7 or 14 day step size. I put in a little logic to hide the last day label if it's going to overlap the next month label. You can see this with 3/30 and 3/31 above. |
success in leeoniya/uPlot@66d3e13 in https://leeoniya.github.io/uPlot/bench/uPlot.html, spanning the 12am periods while zooming now shows the difference in initial and follow-up label contexts. could still use some tweaking of the defaults but appears to work as intended and is pretty simple. |
@epezent I can confirm that it works flawlessly on macOS. Good job! :D |
This work is complete, merged, and detailed here: #48 (comment) Woohoo! |
Folks looking for |
Does anyone know how to set the X axis to interpret the UNIX timestamp as milliseconds instead of seconds? I see from above that it should support milliseconds but none of the examples use it as far as I can tell. |
I was wondering if there is something to support time in dd/mm/yy and hours:minutes: seconds on the x-axis vs some data on the y-axis.
The text was updated successfully, but these errors were encountered: