Skip to content

Commit 8ca5840

Browse files
committed
base legend.title.font.size on legend.font not layout.font and default to 20% gt for h legends
1 parent 32d4631 commit 8ca5840

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/components/legend/attributes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ module.exports = {
189189
font: fontAttrs({
190190
editType: 'legend',
191191
description: [
192-
'Sets this legend\'s title font.'
192+
'Sets this legend\'s title font.',
193+
'Defaulted to `legend.font`.',
194+
'When `orientation` is *h*, the size would be defaulted to be',
195+
'20% greater than the font size used for legend items.'
193196
].join(' '),
194197
}),
195198
side: {

src/components/legend/defaults.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
7777
coerce('bgcolor', layoutOut.paper_bgcolor);
7878
coerce('bordercolor');
7979
coerce('borderwidth');
80-
Lib.coerceFont(coerce, 'font', layoutOut.font);
80+
var itemFont = Lib.coerceFont(coerce, 'font', layoutOut.font);
8181

8282
var orientation = coerce('orientation');
83+
var isHorizontal = orientation === 'h';
8384
var defaultX, defaultY, defaultYAnchor;
8485

85-
if(orientation === 'h') {
86+
if(isHorizontal) {
8687
defaultX = 0;
8788

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

120121
var titleText = coerce('title.text');
121122
if(titleText) {
122-
coerce('title.side', orientation === 'h' ? 'left' : 'top');
123-
Lib.coerceFont(coerce, 'title.font', layoutOut.font);
123+
coerce('title.side', isHorizontal ? 'left' : 'top');
124+
var dfltTitleFont = Lib.extendFlat({}, itemFont, {
125+
size: itemFont.size * (isHorizontal ? 1.2 : 1)
126+
});
127+
128+
Lib.coerceFont(coerce, 'title.font', dfltTitleFont);
124129
}
125130
};

0 commit comments

Comments
 (0)