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

No last tick on X time scale. #2560

Closed
Kopleman opened this issue May 16, 2016 · 9 comments · Fixed by #3064
Closed

No last tick on X time scale. #2560

Kopleman opened this issue May 16, 2016 · 9 comments · Fixed by #3064

Comments

@Kopleman
Copy link
Contributor

Hello and thank you for great Chart.js.
I dont know exactly is is a bug or maybe i missed some option but I have a strange behaviour of X time-scale - every chart that i have with huge amount of points/time(thats way i cant create plunker, sorry) have same thing there is no last time tick on X scale
2016-05-16_08-20-18

@etimberg
Copy link
Member

@Kopleman I think this is an rounding error in the code. There is some code to determine if the 2nd last and last labels will overlap. If so, the code prioritizes the last label for display. Looks like this is accidentally triggering in this case

@awallat
Copy link
Contributor

awallat commented Jul 1, 2016

I have the same problem and I created a jsbin for this behaviour:
http://jsbin.com/jofocuditu/edit?html,output

@leonexcc
Copy link

This can also happen if you use labels and autoSkip kicks in:
http://jsbin.com/lixixekuja/1/edit?html,output
(You might have to adjust the browser window because jsbin adjusts the canvas automatically. If the canvas gets small enough you can see the same problem as above)

@theawesomenayak
Copy link
Contributor

theawesomenayak commented Jul 17, 2016

This and #2964 are the same issue. Its caused due to miscalculation in the scaleSizeInUnits variable. If you look at the buildTicks function in scale.time.js, the value of me.scaleSizeInUnits is derived from lastTick.

me.scaleSizeInUnits = me.lastTick.diff(me.firstTick, me.tickUnit, true);

But the value of lastTick itself is changed much later down the function.

I tried moving the lastTick calculation to the top, but it breaks 3 test cases.

  • 'Should use the isoWeekday option'
  • 'should get the correct pixel for a value'
  • 'should get the correct label for a data value'

The charts come out perfecly though. Any thoughts @etimberg ?

image

image

@etimberg
Copy link
Member

What do the test failures look like?

@theawesomenayak
Copy link
Contributor

PFA the error log. All other tests in the same script which test for the ticks pass.
time-scale-error.txt

@etimberg
Copy link
Member

@sibennayak two of those tests look like something being undefined. The third looks like some pixel values changed (which would be kind of worrying)

@etimberg
Copy link
Member

@sibennayak I have a PR based on your suggestion in #3064

@ailsamm
Copy link

ailsamm commented Oct 12, 2023

@Kopleman I think this is an rounding error in the code. There is some code to determine if the 2nd last and last labels will overlap. If so, the code prioritizes the last label for display. Looks like this is accidentally triggering in this case

Thank you for this hint! I had this exact issue. My max was being calculated as 95.45. There should have been a tick at 90, but it wasn't displaying at all. I rounded my max to one decimal place (95.5) and boom –– the tick at 90 displayed!

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

Successfully merging a pull request may close this issue.

7 participants