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

New defaults for colorbar.title.font and legend.title.font to depend on colorbar.tickfont and legend.font and increase their sizes #5611

Merged
merged 13 commits into from
May 5, 2021

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Apr 26, 2021

Closes #5595.

  1. Instead of using legend.font, the layout.font used to be applied as the default for legend.title.font.
    This PR fixes that.

  2. Instead of using colorbar.tickfont, the layout.font used to be applied as the default for colorbar.title.font.
    This PR fixes that too.

  3. The legend.title.font.size would be defaulted to be around 20% greater than the legend.font.

  4. The colorbar.title.font.size would be defaulted to be around 20% greater than the colorbar.tickfont.

  5. The gap between legend.title and items is increased when legend.title.side is set to left.

@plotly/plotly_js

@archmoj archmoj added bug something broken status: reviewable labels Apr 26, 2021
@archmoj archmoj added this to the NEXT milestone Apr 26, 2021
@nicolaskruchten
Copy link
Contributor

Will you do the vertical-centering in another PR or in this one?

I notice that none of the mocks have just the normal default behaviour of "a short three word legend title on a single line with no styling" so it's hard to see in the baseline diffs what the final outcome is

@archmoj
Copy link
Contributor Author

archmoj commented Apr 26, 2021

Will you do the vertical-centering in another PR or in this one?

We could add that feature if this left default is not good enough.

@archmoj
Copy link
Contributor Author

archmoj commented Apr 26, 2021

I notice that none of the mocks have just the normal default behaviour of "a short three word legend title on a single line with no styling" so it's hard to see in the baseline diffs what the final outcome is

Good call. I should add/adjust mocks to show the default.

@nicolaskruchten
Copy link
Contributor

We should at least add the ability to do middle left and have that be the default.

Perhaps it's not a great default when the horizontal legend is multiple lines? we can set it to default to left if the legend is taller than some cutoff maybe? cc @alexcjohnson ?

@nicolaskruchten
Copy link
Contributor

Or maybe the right heuristic is to redefine "left" to mean "the centerline of the title bounding box is colinear with the centerline of the top-most legend item" ?

@nicolaskruchten
Copy link
Contributor

OK so right now just changing the font size gives much better vertical alignment, mostly by accident: the baselines of the text are aligned.

Some additional things to do here:

  1. make the font size of the legend title the same as the xaxis.title (it's not exactly the same atm?)
  2. make the font size change for both legend orientations
  3. make the font size change for colorbar titles also

@archmoj archmoj changed the title Fixup defaults for legend title.font.size and increase size when orientation is horizontal Fixup defaults for legend title.font.size to depend on title.font and increase the size May 3, 2021
@archmoj archmoj changed the title Fixup defaults for legend title.font.size to depend on title.font and increase the size Fixup defaults for legend legend.title.font.size to depend on title.font and increase the size May 3, 2021
@archmoj archmoj changed the title Fixup defaults for legend legend.title.font.size to depend on title.font and increase the size Fixup defaults for legend.title.font to depend on legend.font and increase its size May 3, 2021
@archmoj archmoj changed the title Fixup defaults for legend.title.font to depend on legend.font and increase its size Fixup defaults for colorbar.title.font and legend.title.font to depend on legend.font and increase the sizes May 4, 2021
@archmoj archmoj changed the title Fixup defaults for colorbar.title.font and legend.title.font to depend on legend.font and increase the sizes New defaults for colorbar.title.font and legend.title.font to depend on colorbar.tickfont and legend.font and increase their sizes May 4, 2021

var tickFont = colorbarOut.tickfont;
var dfltTitleFont = Lib.extendFlat({}, tickFont, {
color: font.color,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here the colorbar.title.font.color depends on layout.font not tickfont so that with inside ticklabels getting white, it renders outside using #444.

@@ -144,7 +144,7 @@
"legend": {
"orientation": "h",
"title": {
"text": "<b>bar, funnel & waterfall</b><br>textangle:-45"
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of removing all the <b> tags in titles?

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 question.
To make it easier to see what the default look like.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK - we have other examples of styled text, so this is fine.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃

@archmoj archmoj merged commit 8ab0260 into master May 5, 2021
@archmoj archmoj deleted the legend-title-size branch May 5, 2021 17:06
@archmoj archmoj mentioned this pull request May 19, 2021
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Legend title in horizontal mode is misaligned and ambiguously sized
3 participants