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

Add reverse support to category scale #6342

Closed
wants to merge 5 commits into from
Closed

Conversation

nagix
Copy link
Contributor

@nagix nagix commented Jun 15, 2019

This PR adds ticks.reverse support to category scale as well as the refactoring discussed in #6323 (comment).

This PR: https://jsfiddle.net/nagix/at8vfh6x/
Screen Shot 2019-06-15 at 5 31 47 PM

Closes #3306

etimberg
etimberg previously approved these changes Jun 15, 2019
@nagix
Copy link
Contributor Author

nagix commented Jun 15, 2019

Added a boundary check at the end of getValueForPixel.

@kurkle
Copy link
Member

kurkle commented Jun 15, 2019

Just FYI, I did something similar the other day. Handled the reverse thing in core.scale. Its based on layout refactor, so can't PR yet (also not near computer for weekend)

Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

you may also be able to use the new method in scale.linear/logarithmic.getPixelForValue/getValueForPixel

convertTicksToLabels: function() {
var me = this;

me._tickValues = me.ticks.slice();
Copy link
Contributor

@benmccann benmccann Jun 15, 2019

Choose a reason for hiding this comment

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

can we either make this not necessary or add a comment explaining why it's needed? it seems redundant to me that we would store ticks in both ticks and _tickValues

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment added. The labels need to be stored because they can be modified by the user callback while getPixelForValue requires the original label value.

src/core/core.scale.js Outdated Show resolved Hide resolved
@nagix
Copy link
Contributor Author

nagix commented Jun 17, 2019

getPixelForValue/getValueForPixel for logarithmic scale were refactored. I tried to refactor those methods for linear scale, but didn't include it because the size increased.

@nagix
Copy link
Contributor Author

nagix commented Jun 17, 2019

@kurkle I'm happy to review your code once the layout refactoring completes.

@DevidCIC
Copy link

Any updates on this ?
I see that if the Y-Axis consists of numbers then setting the reversed flags works. But if the Y-Axis consists of letters than the reversed does not work.

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.

Reversing xAxes ticks doesn't seem to work.
5 participants