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

Wrong year assigned to a ticklabel in plotly.js #6457

Closed
pedrogarcia1965 opened this issue Jan 31, 2023 · 4 comments
Closed

Wrong year assigned to a ticklabel in plotly.js #6457

pedrogarcia1965 opened this issue Jan 31, 2023 · 4 comments

Comments

@pedrogarcia1965
Copy link

The following image contains a part of a scatter plot generated with plotly.js:

image

The red arrow shows the wrong value in ticklabel. It should be 53 2020.

If a zoom is made, then the right ticklabels are obtained:

image

This problem appears just when the ticklabel is generated when date is December 31st of any year.

One attention calling point is that the value of showed data in the first image when the mouse is over the point (following the green arrow), is the right one: 53, 2020!

The code for this issue can be found at: codepen

After a little research, a possible cause of issue could be related to:

  • Plotly uses Date.getUTCFullyear to calculate ticklabels,

  • For a date given on December 31st, the result may be different according to getUTCFullYear in MDN.

??

Or, is there any other cause producing this issue?

Please, can anyone help to solve it? Thanks.

@28raining
Copy link
Contributor

It's an issue in d3-time-format
Filed issue: d3/d3-time-format#120

@28raining
Copy link
Contributor

Sometimes the last week of the year is week 1, like in 2019. But not in 2020
http://www.whatweekisit.org/calendar-2020.html

@28raining
Copy link
Contributor

OK this doesn't seem to be a real issue.

The first week of 2021 is called week 53: http://www.whatweekisit.org/calendar-2021.html

Because tickmode="auto", the first tick is drawn probably at 2021-01-01, which is week 53 of 2021.

It should be possible to get exactly the ticks you want by using tickvals.
I tried with tickmode="linear" but couldn't get nice results, perhaps you could file a separate ticket.

@gvwilson
Copy link
Contributor

Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson

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

No branches or pull requests

3 participants