-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Date auto-formatting on xaxis #99
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
Comments
@prog8 It is possible to customize the tick format for date using the See this example json and associated png.
Hope this helps. |
Thank you for your answer. I think we misunderstood each other. I know that it is possible to use customer formatting of x axis but as I wrote in previous message when I decide to use custom formatting I lose ability to use auto-formatting when I zoom in and out. Let's imagine that I open a chart for whole year. It makes sense of course to show "%b %y" only but when I keep zooming in it would makes sense to show days, hours, minutes and even seconds. Am I missing something? |
@prog8 My mistake. I didn't catch your mention of
That sounds like a pretty hard behavior to generalize in a declarative matter. What does a little mean? How would that work? A potential solution would use a custom on-zoom handler (which doesn't exist yet, similar to |
I know that this can be hard to generalize but I was wondering why default behavior produces things like full date in the first tick and hour format like "09h" which is not what an average user could expect. |
@prog8 can you paste a reproducible example of this behavior? Debugging from a screenshot is hard. |
@etpinard sure. Here is an example: data series, layout, config
|
@prog8 Interesting. With your specs, no |
Maybe another library is conflicting with plotly.js on your page. |
Even when you zoom out? |
@prog8 Ah. Now I see it. Investigating .... |
This is the expected behavior but we can debate whether that's really ideal. We need to have the date in this case, because you commonly span into a second day, and I thought |
A bit late, but I was wondering this as well. |
My thoughts are similar to most charting libraries the tick format to be configurable as a function, pseudo code would be something like:
I'm pretty desperate to have better controller over the formatting of the time series x-axis as it currently just doesn't look right/good so I will attempt to add this functionality. Will let you know how I go. |
tick format should be configurable as a function for y-axis as well. Currently could not find an example where we show alphanumeric text in y-axis (E.g. Traffic in bytes) |
Okay. I dived deep into this one and came up with the following result: Basically I wanted the auto formatted x-axis ticks to show the first tick as the hour, day and month and every tick that is midnight to also display the hour, day and month. I think this looks much better than the default hour tick which was %b %-d %Hh and had the year on a new line. I investigated making tickformat a function, and also using the tickmode 'array' and manually calculating the ticks to pass into Plotly plot function however these options were quite complex/looked very time consuming to complete. What I ended up doing was manually modifying the formatDate function of Ploty to the following:
} It's a bit of a hacky solution but it provided me with the best time to result. I'm not sure what the better long term solution for Plotly would be but I think opening up the auto tick date formats as layout configuration options, maybe have options for the format of first tick, hour tick marks, and midnight tick marks? Hope that helps someone. EDIT: Fixed image link. |
the "09h" type format has been removed from the auto-formatting routine as part of #1078 - this also changes some other subtle bits of the formatting, like in cases where the date got pushed to a second line, now it shows up on every tick where the date changes, rather than just the first tick. This doesn't give the full flexibility folks had discussed above, but it does address the most common reason you WANTED that flexibility. Going to close this for now, but feel free to reopen or open a new issue with a specific use case that would benefit from more flexibility. Thanks for the discussion! |
Hi,
I tried to open a topic on http://community.plot.ly/c/plotly-js but always get a message "Something has gone wrong. Perhaps this topic was closed or deleted while you were looking at it?" so I'm writing here
Is it possible to keep auto-formatting of date depending on range but adjust it a little? Let me explain my case.
Plotly formats date automatically. When year is not needed it skips the year in format but not always. Look at the screenshot above. You can see that first tick always contains a date. Moreover in this case "Dec 9" doesn't have to be shown in all ticks. It can be skipped but it is not. Hour is also displayed in a strange way. I would rather expect something like "7 AM" or "7:00" instead of "07h". I know that I can use tickformat but this totally destroys automatic formatting. It also looks like tickformat cannot be any function which would implement auto-formatting. Any ideas?
The text was updated successfully, but these errors were encountered: