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

New time scale ticks.bounds option #4556

Merged
merged 1 commit into from Jul 25, 2017

Conversation

simonbrunel
Copy link
Member

@simonbrunel simonbrunel commented Jul 24, 2017

Edit: renamed scale.ticks.bounds to scale.bounds in #4595

--

bounds ('data' (default)|'ticks'): data preserves the data range while ticks ensures that all labels are visible. This option is bypassed by the min/max time options.

Remove the useless time scale _model object containing private members: instead, make these members private (prefixed by _) part of the scale.

image

Fixes #2249
Fixes #2513
Fixes #2599
Fixes #2684
Fixes #2774
Fixes #3297
Fixes #3654
Fixes #3671
Fixes #4263
Fixes #4264
Fixes #4529
Fixes #4550

@simonbrunel
Copy link
Member Author

image

Interesting ...

@simonbrunel
Copy link
Member Author

The master implementation is equivalent to ticks.bounds: 'labels' but based on the many reported issues regarding the trailing and leading gaps, I think it's better to change it for ticks.bounds: 'data'.

@benmccann
Copy link
Contributor

Wow, amazing to close so many tickets!


/**
* Ticks distribution along the scale:
* - 'linear': ticks are spread according to their time (distances can vary),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more accurate to say data rather than ticks here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or rather maybe more informative to say "ticks and data"

When source:auto mode, we try to place ticks spread evenly regardless of mode so I think it helps explain it better if we mention data as well

@benmccann
Copy link
Contributor

looks good to me

`ticks.bounds` (`'data'`(default)|`'label'`): `data` preserves the data range while `labels` ensures that all labels are visible. This option is bypassed by the min/max time options.

Remove the useless time scale `_model` object containing private members: instead, make these members private (prefixed by `_`) part of the scale.
@simonbrunel
Copy link
Member Author

And I'm sure I missed some tickets

@simonbrunel simonbrunel merged commit 3aa7a20 into chartjs:master Jul 25, 2017
@simonbrunel simonbrunel deleted the ticks-bounds branch July 25, 2017 08:12
@dabrave
Copy link

dabrave commented Jul 27, 2017

Hi Simon and everyone!

First of all congrats to you all for such great community! 🥇 🥇 🥇

Tried with your last update for this issue (is it included on ChartJS 2.6 right? Or do I have to upgrade the code manually on src/scales/scale.time.js ?)

Maybe I'm implementing the solution wrong... Below you can see how (tried with just one tick.bounds on xAxis and both, but nothing...) As you can see there are still some dates not included on the chart.

2017-07-27_1851

2017-07-27_1854

Hope one day I could contribute in any code here, Cheers!

@benmccann
Copy link
Contributor

This isn't included in 2.6.0. You have to checkout the latest code from github, build it (npm install & gulp build), and then use the version you compiled

@simonbrunel
Copy link
Member Author

simonbrunel commented Jul 27, 2017

It's not released yet, you will have to wait the next release (2.7). However you can try the latest build from master (for testing only - do not pay attention to the version number in this file) and see if it works as you expect. bounds is only applicable to the time scale right now (so will have no effect on your y-axis).

@simonbrunel
Copy link
Member Author

Also, I don't think beginAtZero is used by the time scale.

@dabrave
Copy link

dabrave commented Jul 27, 2017

Ok cool, thanks a lot for such quick answer guys! :)

nagix pushed a commit to nagix/Chart.js that referenced this pull request Jul 28, 2017
`ticks.bounds` (`'data'`(default)|`'label'`): `data` preserves the data range while `labels` ensures that all labels are visible. This option is bypassed by the min/max time options.

Remove the useless time scale `_model` object containing private members: instead, make these members private (prefixed by `_`) part of the scale.
yofreke pushed a commit to yofreke/Chart.js that referenced this pull request Dec 30, 2017
`ticks.bounds` (`'data'`(default)|`'label'`): `data` preserves the data range while `labels` ensures that all labels are visible. This option is bypassed by the min/max time options.

Remove the useless time scale `_model` object containing private members: instead, make these members private (prefixed by `_`) part of the scale.
exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
`ticks.bounds` (`'data'`(default)|`'label'`): `data` preserves the data range while `labels` ensures that all labels are visible. This option is bypassed by the min/max time options.

Remove the useless time scale `_model` object containing private members: instead, make these members private (prefixed by `_`) part of the scale.
@maysam
Copy link

maysam commented Feb 1, 2022

@dabrave did an update fixed your problem? because I'm facing similar problem with version 2.9.4

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