Skip to content

Commit 24ed9c9

Browse files
committed
add subtitle property and simple prototype
1 parent caf32e5 commit 24ed9c9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/components/titles/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ function draw(gd, titleClass, options) {
7575
var fontLineposition = font.lineposition;
7676
var fontShadow = font.shadow;
7777

78+
// Get subtitle properties
79+
var subtitle = cont.title.subtitle;
80+
var subtitleTxt = (subtitle && subtitle.text ? subtitle.text : '').trim();
81+
console.log({
82+
titleTxt: txt,
83+
subtitleTxt: subtitleTxt,
84+
});
85+
// Prototype for subtitle: Use HTML tags to tack subtitle onto title
86+
if(subtitleTxt) {
87+
txt = txt + '<br><sub>' + subtitleTxt + '</sub>';
88+
}
89+
7890
// only make this title editable if we positively identify its property
7991
// as one that has editing enabled.
8092
var editAttr;

src/plots/layout_attributes.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ globalFont.family.dflt = '"Open Sans", verdana, arial, sans-serif';
2020
globalFont.size.dflt = 12;
2121
globalFont.color.dflt = colorAttrs.defaultLine;
2222

23+
2324
module.exports = {
2425
font: globalFont,
2526
title: {
@@ -41,6 +42,18 @@ module.exports = {
4142
'by the now deprecated `titlefont` attribute.'
4243
].join(' ')
4344
}),
45+
subtitle: {
46+
text: {
47+
valType: 'string',
48+
editType: 'layoutstyle',
49+
description: 'Sets the plot\'s subtitle.'
50+
},
51+
font: fontAttrs({
52+
editType: 'layoutstyle',
53+
description: 'Sets the subtitle font.'
54+
}),
55+
editType: 'layoutstyle',
56+
},
4457
xref: {
4558
valType: 'enumerated',
4659
dflt: 'container',

0 commit comments

Comments
 (0)