8000 Implement bar labels (issue 34) by n-riesco · Pull Request #1159 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bar: bar texts only rotate clockwise
  • Loading branch information
n-riesco committed Nov 17, 2016
commit f7806c85cbf4de6c5938b04616bb064d216afdd8
8 changes: 3 additions & 5 deletions src/traces/bar/plot.js
< 5AE4 td id="diff-e5a908bc8cc6eacabde0c549eb2b81bf2d4c256eb19b160e572e65c581fbd80bR423" data-line-number="423" class="blob-num blob-num-context js-linkable-line-number js-blob-rnum">
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function getTransformToMoveInsideBar(x0, x1, y0, y1, textBB, orientation) {
scale = Math.min(barHeight / textWidth, barWidth / textHeight);
}

if(rotate) rotate = -90; // rotate counter-clockwise
if(rotate) rotate = 90; // rotate clockwise

// compute text and target positions
if(rotate) {
Expand Down Expand Up @@ -388,6 +388,8 @@ function getTransformToMoveOutsideBar(x0, x1, y0, y1, textBB, orientation) {
scale = barWidth / textHeight;
}

if(rotate) rotate = 90; // rotate clockwise

// compute text and target positions
var textX = (textBB.left + textBB.right) / 2,
textY = (textBB.top + textBB.bottom) / 2,
Expand All @@ -409,25 +411,21 @@ function getTransformToMoveOutsideBar(x0, x1, y0, y1, textBB, orientation) {
// bar end is on the left hand side
targetX = x1 - textpad - targetWidth / 2;
targetY = (y0 + y1) / 2;
if(rotate) rotate = -90; // rotate counter-clockwise
}
else {
targetX = x1 + textpad + targetWidth / 2;
targetY = (y0 + y1) / 2;
if(rotate) rotate = 90; // rotate clockwise
}
}
else {
if(y1 > y0) {
// bar end is on the bottom
targetX = (x0 + x1) / 2;
targetY = y1 + textpad + targetHeight / 2;
if(rotate) rotate = -90; // rotate counter-clockwise
}
else {
targetX = (x0 + x1) / 2;
targetY = y1 - textpad - targetHeight / 2;
if(rotate) rotate = 90; // rotate clockwise
}
}

Expand Down
0