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 position ticks in time scale with offsetGridLines #5490

Open
alexandre-tobia opened this issue May 14, 2018 · 6 comments
Open

Wrong position ticks in time scale with offsetGridLines #5490

alexandre-tobia opened this issue May 14, 2018 · 6 comments

Comments

@alexandre-tobia
Copy link

alexandre-tobia commented May 14, 2018

Hi,

I'm using chartjs latest version (2.7.2).

I'm using offsetGridLines: true to center my xAxes label (2016, 2017,...), but since i use this options, my points are not in the right position.

For example, this point need to be between the red lines (because it belongs to 2016)

Image of Yaktocat

jsfidle: https://jsfiddle.net/mrbmvd19/1/ (look at the 2016-12-01)

Do you know how to do that?

Thanks a lot.

@alexandre-tobia alexandre-tobia changed the title Wrong position ticks in time scale Wrong position ticks in time scale with offsetGridLines May 14, 2018
@etimberg
Copy link
Member

@alexandre-tobia offsetGridLines also centers the values, so 2017 starts at the 2017 label.

@simonbrunel thoughts on a way to improve this?

@alexandre-tobia
Copy link
Author

@etimberg unfortunately yes...

so, in this case, the vertical line become totally useless (and meaningless ), maybe an option to avoid values to be automaticaly centered ?

@ahukkanen
Copy link

This was also confusing me. Investigating further...

@ahukkanen
Copy link

Got this working so that at least when I'm using the time scale for years, it splits the years with the grid lines and prints the year label in the middle of the year.

Here's an example that has been tested with Chart.js v2.7.3:
https://gist.github.com/ahukkanen/fe69a70c3708b32210fd18860ba609c5

@ahukkanen
Copy link

Is this a bug by the way or intended behavior? This was totally confusing to me at first before I found this issue.

@kurkle
Copy link
Member

kurkle commented Mar 24, 2021

Does not look like an issue in v3 anymore?: https://jsfiddle.net/n5dbt2ue/
Could be actually fixed in 2.9 already, did not test.

Edit: nevermind
image

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

No branches or pull requests

4 participants