Skip to content

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

Merged
merged 8 commits into from
Aug 5, 2017
Merged

Bar text constraint configuration #1931

merged 8 commits into from
Aug 5, 2017

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Aug 4, 2017

This PR does two things:

  1. adds constraintext: 'both' | 'none' | 'inside' | 'outside' in order to resolve this comment on 'marker+text' mode for bar charts #34.
  2. slightly modifies the 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.

@rreusser rreusser changed the title Bar text contraint configuration Bar text constraint configuration Aug 5, 2017
@@ -95,6 +95,7 @@ describe('Bar.supplyDefaults', function() {
expect(traceOut.texfont).toBeUndefined();
expect(traceOut.insidetexfont).toBeUndefined();
expect(traceOut.outsidetexfont).toBeUndefined();
expect(traceOut.constraintext).toBe();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks odd... toBeUndefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Good catch.

Copy link
Contributor Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good call.

}

// compute rotation and scale
var rotate = false,
var rotate = false;
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔪 'd

@alexcjohnson
Copy link
Collaborator

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 💃

@rreusser
Copy link
Contributor Author

rreusser commented Aug 5, 2017

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.

@rreusser rreusser merged commit 98377fc into master Aug 5, 2017
@rreusser rreusser deleted the bar-text-contraints branch August 5, 2017 04:45
@etpinard etpinard added this to the v1.30.0 milestone Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'marker+text' mode for bar charts
3 participants