Skip to content

Incorrect automatic date labels on X axis #482

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

Closed
meglio opened this issue Apr 28, 2016 · 10 comments
Closed

Incorrect automatic date labels on X axis #482

meglio opened this issue Apr 28, 2016 · 10 comments
Labels
bug something broken

Comments

@meglio
Copy link

meglio commented Apr 28, 2016

Data is provided from Apr 7 to Apr 22:

image

The very first X-label says Apr 8.
Expected: Apr 9 (3rd day starting from Apr 7).

The conflict also can be clearly seen when mouse-hovering the corresponding data point:

image


Data for bug reproduction

Days (X axis):

["2016-04-07","2016-04-08","2016-04-09","2016-04-10","2016-04-11","2016-04-12","2016-04-13","2016-04-14","2016-04-15","2016-04-16","2016-04-17","2016-04-18","2016-04-19","2016-04-20","2016-04-21","2016-04-22"]

Number of responses (Y axis):

[1,0,0,0,0,0,0,0,1,0,0,2,0,0,0,6]
@etpinard
Copy link
Contributor

@meglio I can't reproduce this.

Here's what I tried: http://codepen.io/etpinard/pen/ONBmrx

@meglio
Copy link
Author

meglio commented Apr 28, 2016

What you are showing in codepen demonstrates the bug.
Mouse hover where the x-axis label says "Apr 8" and it will show a black popup saying "Apr 9":

image

@etpinard
Copy link
Contributor

Ah it must be a timezone-related issue.

Here's what I'm getting:

image

This issue is possible a duplicated of #171

@meglio
Copy link
Author

meglio commented Apr 28, 2016

The dates I'm feeding to Plotly.js are in format YYYY-MM-DD - they contain no timezone information at all. Still can be a timezone issue?

What is confusing is that the black popup labels along the X axis are still correct. The static X-labels is what is wrong.

@etpinard
Copy link
Contributor

@meglio
Copy link
Author

meglio commented Apr 28, 2016

If this is a timezone issue, how can it be that static labels are incorrect while the hover labels are correct? I would expect both to be incorrect in such a case.

@etpinard
Copy link
Contributor

If you zoom in on that point, you'll see that the label and data point aren't exactly at the same location. They should be a few hours apart, one on April 8, one on April 9.

@etpinard etpinard added the bug something broken label May 16, 2016
@alexcjohnson
Copy link
Collaborator

This seems to have been fixed - probably by #1194. Feel free to reopen if you still see the problem.

@Bootcampanalytics
Copy link

Hi,

It seems that I run into the same issue again, but now it's on month level. This is not a timezone issue, is it?

https://plot.ly/~olavl/6/#plot

The hover date is correct, the x-axis label date not.

@alexcjohnson
Copy link
Collaborator

@analytics-bootcamp you're right, that's not a timezone issue. The issue there is that we automatically put the label "Aug 2018" at August 1, which is essentially at your bar for July 31. The ticks are not labeling the bars, though in this case they're very close to the bars, they're labeling axis positions.

You can force the behavior you want with eg:

Plotly.relayout(gd,{
    'xaxis.tick0':'2000-01-31', // canonical tick on the last day of the month
                                // (which automatically sets tickmode: 'linear')
    'xaxis.dtick':'M1', // can't use auto ticks with tick0, so you have to specify 1-month ticks
    'xaxis.tickformat':'%b %Y' // eg 'Jul 2018', otherwise we'll show 'Jul 31'
                               // (and year when necessary)
})

I'm not really sure how we could figure out automatically that this is what you want though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

4 participants