Skip to content

Change scale.ticks back to an array of strings#4573

Merged
simonbrunel merged 2 commits intochartjs:masterfrom
simonbrunel:fix/scale-ticks-private
Jul 29, 2017
Merged

Change scale.ticks back to an array of strings#4573
simonbrunel merged 2 commits intochartjs:masterfrom
simonbrunel:fix/scale-ticks-private

Conversation

@simonbrunel
Copy link
Member

@simonbrunel simonbrunel commented Jul 27, 2017

Internal ticks are now stored as objects in the PRIVATE this._ticks member and must not be accessed directly from outside this class. this.ticks is around for a long time and hasn't been marked as private, so we can't change its structure without unexpected breaking changes. If you need to access the scale ticks, use scale.getTicks() instead.

Fixes #4502 (regression introduced in #4268)

Internal ticks are now stored as objects in the PRIVATE this._ticks member and must not be accessed directly from outside this class. this.ticks is around for a long time and hasn't been marked as private, so we can't change its structure without unexpected breaking changes. If you need to access the scale ticks, use scale.getTicks() instead.
@simonbrunel simonbrunel added this to the Version 2.7 milestone Jul 27, 2017
@simonbrunel simonbrunel requested a review from etimberg July 27, 2017 13:02
@benmccann
Copy link
Contributor

benmccann commented Jul 27, 2017

Thanks. I'll take a look at this one sometime in the next few days


me.beforeTickToLabelConversion();
me.convertTicksToLabels();
labels = me.convertTicksToLabels(ticks) || me.ticks;
Copy link
Member

Choose a reason for hiding this comment

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

is || me.ticks correct? Should it be || ticks ?

Copy link
Member Author

@simonbrunel simonbrunel Jul 28, 2017

Choose a reason for hiding this comment

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

Yes, it's me.ticks in case of a sub class that convertTicksToLabels in place and so modify me.ticks directly without returning it. I know it's pretty confusing, I will add a comment.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, makes sense 👍

// Ticks
me.beforeBuildTicks();
me.buildTicks();
ticks = me.buildTicks() || [];
Copy link
Member

Choose a reason for hiding this comment

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

is changing this to return breaking?

Copy link
Member Author

@simonbrunel simonbrunel Jul 28, 2017

Choose a reason for hiding this comment

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

I hope not: if buildTicks doesn't return anything, that means it's the old implementation that directly store ticks in this.ticks. It also means this same object will be used by the old implementation of convertTicksToLabels (the base one still use me.ticks).

Here, ticks is supposed to be an array of objects: if nothing is returned, it's re-synchronized with labels bellow (and so me.ticks for old impl.).

@simonbrunel
Copy link
Member Author

@etimberg I added some comments to hopefully make it clearer. If not, let me know :)

@simonbrunel simonbrunel merged commit 53b7a63 into chartjs:master Jul 29, 2017
@simonbrunel simonbrunel deleted the fix/scale-ticks-private branch July 29, 2017 19:26
yofreke pushed a commit to yofreke/Chart.js that referenced this pull request Dec 30, 2017
Internal ticks are now stored as objects in the PRIVATE this._ticks member and must not be accessed directly from outside this class. this.ticks is around for a long time and hasn't been marked as private, so we can't change its structure without unexpected breaking changes. If you need to access the scale ticks, use scale.getTicks() instead.
exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
Internal ticks are now stored as objects in the PRIVATE this._ticks member and must not be accessed directly from outside this class. this.ticks is around for a long time and hasn't been marked as private, so we can't change its structure without unexpected breaking changes. If you need to access the scale ticks, use scale.getTicks() instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants