Skip to content

Bar text constraint configuration#1931

Merged
rreusser merged 8 commits into
masterfrom
bar-text-contraints
Aug 5, 2017
Merged

Bar text constraint configuration#1931
rreusser merged 8 commits into
masterfrom
bar-text-contraints

Conversation

@rreusser

@rreusser rreusser commented Aug 4, 2017

Copy link
Copy Markdown
Contributor

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
Comment thread test/jasmine/tests/bar_test.js Outdated
expect(traceOut.texfont).toBeUndefined();
expect(traceOut.insidetexfont).toBeUndefined();
expect(traceOut.outsidetexfont).toBeUndefined();
expect(traceOut.constraintext).toBe();

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread src/traces/bar/plot.js

// 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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah, good call.

Comment thread src/traces/bar/plot.js Outdated

// compute rotation and scale
var rotate = false,
var rotate = false;

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

rreusser commented Aug 5, 2017

Copy link
Copy Markdown
Contributor Author

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