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

Implement bar labels (issue 34) #1159

Merged

Conversation

n-riesco
Copy link
Contributor

This PR implements the bar attributes text, textposition, textfont, insidetextfont and outsidetextfont to address issue #34.

The review for this PR can be found here.

* 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).
@etpinard
Copy link
Contributor

Awesome work @n-riesco !

@etpinard etpinard merged commit 0fc99c6 into plotly:master Nov 24, 2016
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.

None yet

2 participants