Skip to content

Commit

Permalink
sub metatext -> meta
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Jan 16, 2019
1 parent 4201f0a commit b03e777
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/components/annotations/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {

var font = options.font;

var text = fullLayout.metatext ?
Lib.templateString(options.text, {metatext: fullLayout.metatext}) :
var text = fullLayout.meta ?
Lib.templateString(options.text, {meta: fullLayout.meta}) :
options.text;

var annText = annTextGroupInner.append('text')
Expand Down
4 changes: 2 additions & 2 deletions src/components/titles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ function draw(gd, titleClass, options) {
if(!editable) txt = '';
}

if(fullLayout.metatext) {
txt = Lib.templateString(txt, {metatext: fullLayout.metatext});
if(fullLayout.meta) {
txt = Lib.templateString(txt, {meta: fullLayout.meta});
}

var elShouldExist = txt || editable;
Expand Down
4 changes: 2 additions & 2 deletions src/plots/gl3d/layout/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ proto.merge = function(fullLayout, sceneLayout) {
}

// Axes labels
opts.labels[i] = fullLayout.metatext ?
Lib.templateString(axes.title.text, {metatext: fullLayout.metatext}) :
opts.labels[i] = fullLayout.meta ?
Lib.templateString(axes.title.text, {meta: fullLayout.meta}) :
axes.title.text;

if('font' in axes.title) {
Expand Down
6 changes: 3 additions & 3 deletions src/plots/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,14 @@ module.exports = {
},
editType: 'modebar'
},
metatext: {
meta: {
valType: 'data_array',
editType: 'plot',
description: [
'Assigns extra meta information that can be used in various `text` attributes.',
'Attributes such as the graph, axis and colorbar `title.text` and annotation `text`',
'support `metatext`. One can access `metatext` fields using template strings:',
'`%{metatext[i]}` where `i` is the index of the `metatext`',
'support `meta`. One can access `meta` fields using template strings:',
'`%{meta[i]}` where `i` is the index of the `meta`',
'item in question.'
].join(' ')
},
Expand Down
2 changes: 1 addition & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7));
coerce('modebar.uirevision', uirevision);

coerce('metatext');
coerce('meta');

Registry.getComponentMethod(
'calendars',
Expand Down
8 changes: 4 additions & 4 deletions src/traces/pie/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ module.exports = function plot(gd, cdpie) {
s.attr('data-notex', 1);
});

var txt = fullLayout.metatext ?
Lib.templateString(trace.title.text, {metatext: fullLayout.metatext}) :
var txt = fullLayout.meta ?
Lib.templateString(trace.title.text, {meta: fullLayout.meta}) :
trace.title.text;

titleText.text(txt)
Expand Down Expand Up @@ -480,8 +480,8 @@ function prerenderTitles(cdpie, gd) {
trace = cd0.trace;

if(trace.title.text) {
var txt = fullLayout.metatext ?
Lib.templateString(trace.title.text, {metatext: fullLayout.metatext}) :
var txt = fullLayout.meta ?
Lib.templateString(trace.title.text, {meta: fullLayout.meta}) :
trace.title.text;

var dummyTitle = Drawing.tester.append('text')
Expand Down
30 changes: 15 additions & 15 deletions test/image/mocks/layout_metatext.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,57 +13,57 @@
"type": "surface",
"z": [[1, 2, 3], [1, 2, 1], [3, 2, 1]],
"colorbar": {
"title": {"text": "Product %{metatext[0]}", "side": "right"},
"title": {"text": "Product %{meta[0]}", "side": "right"},
"len": 0.3
}
}, {
"type": "pie",
"labels": ["a", "b", "c"],
"values": [1, 2, 3],
"domain": {"row": 0, "column": 1},
"title": {"text": "Employee %{metatext[1]}"}
"title": {"text": "Employee %{meta[1]}"}
}],
"layout": {
"metatext": ["A", "B", "<b>IMPORTANT</b>", "company<sup>TM</sup>", 1000],
"meta": ["A", "B", "<b>IMPORTANT</b>", "company<sup>TM</sup>", 1000],
"grid": {"rows": 3, "columns": 2, "xgap": 0.2, "ygap": 0.35},
"width": 700,
"height": 800,
"margin": {"b": 40},
"showlegend": false,

"title": {"text": "This graph is %{metatext[2]}"},
"title": {"text": "This graph is %{meta[2]}"},
"xaxis": {
"domain": {"row": 0, "column": 0},
"title": {"text": "Worth more than %{metatext[4]} %{metatext[1]}"}
"title": {"text": "Worth more than %{meta[4]} %{meta[1]}"}
},
"yaxis": {
"domain": {"row": 0, "column": 0},
"title": {"text": "$ by %{metatext[3]}"}
"title": {"text": "$ by %{meta[3]}"}
},
"polar": {
"bgcolor": "#d3d3d3",
"domain": {"row": 1, "column": 0},
"radialaxis": {
"title": {
"text": "%{metatext[3]} -> %{metatext[4]}",
"text": "%{meta[3]} -> %{meta[4]}",
"font": {"color": "red"}
}
}
},
"ternary": {
"domain": {"row": 2, "column": 0},
"aaxis": {"title": {"text": "%{metatext[2]}"}},
"baxis": {"title": {"text": "%{metatext[1]}"}},
"caxis": {"title": {"text": "%{metatext[4]}"}}
"aaxis": {"title": {"text": "%{meta[2]}"}},
"baxis": {"title": {"text": "%{meta[1]}"}},
"caxis": {"title": {"text": "%{meta[4]}"}}
},
"scene": {
"domain": {"row": 1, "column": 1},
"camera": {"eye": {"x": 0.01, "y": 0.01, "z": 2.165}},
"xaxis": {"title": {"text": "AX:%{metatext[1]}"}},
"yaxis": {"title": {"text": "AX:%{metatext[0]}"}},
"zaxis": {"title": {"text": "%{metatext[1]}%{metatext[0]}"}},
"xaxis": {"title": {"text": "AX:%{meta[1]}"}},
"yaxis": {"title": {"text": "AX:%{meta[0]}"}},
"zaxis": {"title": {"text": "%{meta[1]}%{meta[0]}"}},
"annotations": [{
"text": "Look at %{metatext[1]}",
"text": "Look at %{meta[1]}",
"bgcolor": "#d3d3d3",
"borderpad": 2,
"bordercolor": "#000",
Expand All @@ -75,7 +75,7 @@
},

"annotations": [{
"text": "<i>N.B.</i> %{metatext[2]}",
"text": "<i>N.B.</i> %{meta[2]}",
"xref": "x",
"yref": "y",
"x": 1,
Expand Down

0 comments on commit b03e777

Please sign in to comment.