-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Bar text constraint configuration #1931
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
Conversation
test/jasmine/tests/bar_test.js
Outdated
@@ -95,6 +95,7 @@ describe('Bar.supplyDefaults', function() { | |||
expect(traceOut.texfont).toBeUndefined(); | |||
expect(traceOut.insidetexfont).toBeUndefined(); | |||
expect(traceOut.outsidetexfont).toBeUndefined(); | |||
expect(traceOut.constraintext).toBe(); |
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.
This looks odd... toBeUndefined
?
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.
Oops. Good catch.
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.
✅
var barWidth = (orientation === 'h') ? | ||
Math.abs(y1 - y0) : | ||
Math.abs(x1 - x0), | ||
textpad; | ||
|
||
// apply text padding if possible | ||
// Keep the padding so the text doesn't sit right against | ||
// the bars, but don't factor it into barWidth |
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.
Ah, good call.
src/traces/bar/plot.js
Outdated
} | ||
|
||
// compute rotation and scale | ||
var rotate = false, | ||
var rotate = false; |
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.
This may be a silly question but... why do we have an if(rotate)
below if rotate = false
and is never changed?
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.
Good catch. I'll clean it up.
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.
🔪 'd
Looks great. I had also suggested expanding to fill the bar gap for outside text in stacked mode or with only one bar, but that seems a good deal tricker to implement and this is already a big win, so 💃 |
Ah, yeah. So just to confirm, sounds like this wins on pragmatism. Merging, but open to second thoughts if it's worth attacking a more complicated approach. |
This PR does two things:
constraintext: 'both' | 'none' | 'inside' | 'outside'
in order to resolve this comment on 'marker+text' mode for bar charts #34.textpad
for outside text in that it keeps the padding but does not factor it into the width of the bar. That means the text is still offset from the bar just a bit but can grow slightly larger before it's constrained.