-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Allow category scales to use locally-set labels #3732
Conversation
Not sure how to make it more clear...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks fine to me. Can you write a test for this as well?
…m the correct place
Added a test similar to the one above it, named "Should generate ticks from the scale labels" Confirms scale.ticks is equal to config.labels, which is where we get our label data from |
awesome thanks. One last thing, I noticed we use |
Hey, it seems like that line will display the Y-value in the tooltip instead of the value from the category scale (label), if and only if the scale is vertical. If If This is unexpected behavior (not sure how expected it is to get the y-value if on the y-axis, but I think that is outside of this PR). A possible fix for this could be changing |
I personally think your second fiddle is the most correct behaviour. Based on d39ac38 which removed the x check, can we just go ahead and remove this entire if statement and just do This is the original issue where this was added #3278 if we can confirm that this is still fixed after removing this then it is safe to do. |
I looked back at the old commit: the reason it was needed is because |
…ory label. Keeps data.yLabels check in case of previous edgecases
@etimberg I've changed that line to resemble previous functionality. Here is a sample from before the change (same as above): http://codepen.io/albinodrought/pen/eBoZNz Here is a sample from after the change: http://codepen.io/albinodrought/pen/XNQqdw I've left the data.yLabels check in there in case there is an edgecase I'm missing. It currently looks like this:
With this, if only Would something like this make more sense? This would show the values whenever the axis is not horizontal, which makes sense to me - but I might be missing something.
|
I don't think the condition needs to change. Changing it might cause problems for the horizontal bar chart where the y axis is the primary axis. The solution to this might just mean we need to introduce the concept of a "primary" axis direction (horizontal vs vertical) for a chart. Most charts would have horizontal as a primary direction except for the horizontal bar chart. Making those changes is outside the scope of this change though. CC @chartjs/maintainers for further review before this is merged |
ping @etimberg can be closed, I'll fix the remaining issue with another PR. |
Closing per @andig |
Instead of only using data.labels, data.xLabels, or data.yLabels for category scales, also allow users to set labels on the scale config itself.
Example config:
I attempted to update the documentation as specified in
CONTRIBUTING.md
, but I am not sure if it is understandable enough.I've also left the changed function as a one-liner. I'm not sure if it is still okay, or if it should be expanded due to length now.
This implements/fixes #3725
Example functional codepen copy of the issue:
http://codepen.io/albinodrought/pen/ObGVmY