-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Implement bar labels (issue 34) #1159
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
Merged
etpinard
merged 15 commits into
plotly:master
from
n-riesco:pr-20161024-issue-34-textposition-rebased
Nov 24, 2016
Merged
Implement bar labels (issue 34) #1159
etpinard
merged 15 commits into
plotly:master
from
n-riesco:pr-20161024-issue-34-textposition-rebased
Nov 24, 2016
+887
−19
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Added attributes textposition, textfont, insidetextfont and outsidetextfont. * All these attributes accept arrays.
* With the new criteria, bar texts are drawn inside bars except in those cases that would require scaling down.
* Inside texts are rotated only if the rotation helps shrink the text as little as possible. * Outside texts are rotated only if the rotation doesn't leave the text perpendicular to the bar.
* This change ensures inside texts can be drawn, even inside bars smaller than the text padding.
* If rotation is needed: - inside texts are rotated counter-clockwise. - outside texts are rotated clockwise or counter-clockwise, so that the text is laid along the bar end.
* Before this commit, font attributes accepted: [{family: family0, size: size0, color: color0}, {family: family1, size: size1, color: color1}, ...] * With this commit, font attributes accept: {family: [family0, family1, ...], size: [size0, size1, ...], color: [color0, color1, ...]}
* Don't rotate outside labels.
* 'auto' will draw a label inside a bar if larger than drawn outside.
* bar_test.js: Test `textposition`. * bar_test.js: Test that `textposition` can also be restyled. * bar_test.js: Test whether outside bars are correctly identified when `barnorm: 'fraction'`. * bar_attrs_relative: Updated to test the bar text functionality. * bar_attrs_group_norm: Updated to test the bar text functionality. * bar_attrs_relative: Reduced font size of text "Three" to ensure the baseline image also fits the text inside the bar. * bar_attrs_group_norm: Exercise functionality to rotate bar texts. * bar_attrs_group_norm: Use "50%" as bar texts to ensure the bounding box width is larger than its height (unfortunately, this wasn't case when the baseline images were generated using "0.5", because the height of the bounding box includes some white space).
Awesome work @n-riesco ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the bar attributes
text
,textposition
,textfont
,insidetextfont
andoutsidetextfont
to address issue #34.The review for this PR can be found here.