Skip to content

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

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 13 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
5 changes: 4 additions & 1 deletion src/components/legend/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ module.exports = {
font: fontAttrs({
editType: 'legend',
description: [
'Sets this legend\'s title font.'
'Sets this legend\'s title font.',
'Defaulted to `legend.font`.',
'When `orientation` is *h*, the size would be defaulted to be',
'20% greater than the font size used for legend items.'
].join(' '),
}),
side: {
Expand Down
13 changes: 9 additions & 4 deletions src/components/legend/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
coerce('bgcolor', layoutOut.paper_bgcolor);
coerce('bordercolor');
coerce('borderwidth');
Lib.coerceFont(coerce, 'font', layoutOut.font);
var itemFont = Lib.coerceFont(coerce, 'font', layoutOut.font);

var orientation = coerce('orientation');
var isHorizontal = orientation === 'h';
var defaultX, defaultY, defaultYAnchor;

if(orientation === 'h') {
if(isHorizontal) {
defaultX = 0;

if(Registry.getComponentMethod('rangeslider', 'isVisible')(layoutIn.xaxis)) {
Expand Down Expand Up @@ -119,7 +120,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {

var titleText = coerce('title.text');
if(titleText) {
coerce('title.side', orientation === 'h' ? 'left' : 'top');
Lib.coerceFont(coerce, 'title.font', layoutOut.font);
coerce('title.side', isHorizontal ? 'left' : 'top');
var dfltTitleFont = Lib.extendFlat({}, itemFont, {
size: itemFont.size * (isHorizontal ? 1.2 : 1)
});

Lib.coerceFont(coerce, 'title.font', dfltTitleFont);
}
};
7 changes: 7 additions & 0 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ function computeTextDimensions(g, gd, legendObj, aTitle) {
return;
}

var isVertical = helpers.isVertical(legendObj);

var mathjaxGroup = g.select('g[class*=math-group]');
var mathjaxNode = mathjaxGroup.node();
if(!legendObj) legendObj = gd._fullLayout.legend;
Expand Down Expand Up @@ -539,6 +541,11 @@ function computeTextDimensions(g, gd, legendObj, aTitle) {
// approximation to height offset to center the font
// to avoid getBoundingClientRect
if(aTitle === MAIN_TITLE) {
if(!isVertical) {
// add extra space between legend title and itmes
width += constants.titlePad * 2;
}

svgTextUtils.positionText(textEl,
bw + constants.titlePad,
bw + lineHeight
Expand Down
Binary file modified test/image/baselines/bar-like_textangle45.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/bar-like_textangle60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/geo_choropleth-legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_mesh3d_coloring.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/heatmap_legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/uniformtext_bar-like_10_auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/uniformtext_bar-like_8_horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/uniformtext_bar-like_8_textangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/uniformtext_bar-like_8_textangle45.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/uniformtext_pie_16_auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/uniformtext_pie_8_horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/uniformtext_pie_8_horizontal_center.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/uniformtext_pie_8_radial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/uniformtext_pie_8_tangential.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.