Skip to content

Commit b9e6a83

Browse files
committed
add metatext to layout, xy, polar, ternary & colorbar title.text
1 parent 3991552 commit b9e6a83

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/components/titles/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ function draw(gd, titleClass, options) {
9797
if(!editable) txt = '';
9898
}
9999

100+
if(fullLayout.metatext) {
101+
txt = Lib.templateString(txt, {metatext: fullLayout.metatext});
102+
}
103+
100104
var elShouldExist = txt || editable;
101105

102106
if(!group) {

src/plots/layout_attributes.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,17 @@ module.exports = {
409409
},
410410
editType: 'modebar'
411411
},
412+
metatext: {
413+
valType: 'data_array',
414+
editType: 'plot',
415+
description: [
416+
'Assigns extra meta information that can be used in various `text` attributes.',
417+
'Attributes such as the graph, axis and colorbar `title.text` and annotation `text`',
418+
'support `metatext`. One can access `metatext` fields using template strings:',
419+
'`%{metatext[i]}` where `i` is the index of the `metatext`',
420+
'item in question.'
421+
].join(' ')
422+
},
412423
_deprecated: {
413424
title: {
414425
valType: 'string',

src/plots/plots.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,8 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
14551455
coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7));
14561456
coerce('modebar.uirevision', uirevision);
14571457

1458+
coerce('metatext');
1459+
14581460
Registry.getComponentMethod(
14591461
'calendars',
14601462
'handleDefaults'

0 commit comments

Comments
 (0)