Skip to content

Commit 17565f9

Browse files
committed
add metatext support to gl3d axes
1 parent b9e6a83 commit 17565f9

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/plots/gl3d/layout/convert.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var str2RgbaArray = require('../../../lib/str2rgbarray');
12+
var Lib = require('../../../lib');
1313

1414
var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis'];
1515

@@ -66,7 +66,7 @@ function AxesOptions() {
6666

6767
var proto = AxesOptions.prototype;
6868

69-
proto.merge = function(sceneLayout) {
69+
proto.merge = function(fullLayout, sceneLayout) {
7070
var opts = this;
7171
for(var i = 0; i < 3; ++i) {
7272
var axes = sceneLayout[AXES_NAMES[i]];
@@ -83,7 +83,10 @@ proto.merge = function(sceneLayout) {
8383
}
8484

8585
// Axes labels
86-
opts.labels[i] = axes.title.text;
86+
opts.labels[i] = fullLayout.metatext ?
87+
Lib.templateString(axes.title.text, {metatext: fullLayout.metatext}) :
88+
axes.title.text;
89+
8790
if('font' in axes.title) {
8891
if(axes.title.font.color) opts.labelColor[i] = str2RgbaArray(axes.title.font.color);
8992
if(axes.title.font.family) opts.labelFont[i] = axes.title.font.family;
@@ -151,9 +154,9 @@ proto.merge = function(sceneLayout) {
151154
};
152155

153156

154-
function createAxesOptions(plotlyOptions) {
157+
function createAxesOptions(fullLayout, sceneLayout) {
155158
var result = new AxesOptions();
156-
result.merge(plotlyOptions);
159+
result.merge(fullLayout, sceneLayout);
157160
return result;
158161
}
159162

src/plots/gl3d/scene.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ function Scene(options, fullLayout) {
305305
/*
306306
* Move this to calc step? Why does it work here?
307307
*/
308-
this.axesOptions = createAxesOptions(fullLayout[this.id]);
308+
this.axesOptions = createAxesOptions(fullLayout, fullLayout[this.id]);
309309
this.spikeOptions = createSpikeOptions(fullLayout[this.id]);
310310
this.container = sceneContainer;
311311
this.staticMode = !!options.staticPlot;
@@ -406,7 +406,7 @@ proto.plot = function(sceneData, fullLayout, layout) {
406406
this.fullSceneLayout = fullSceneLayout;
407407

408408
this.glplotLayout = fullSceneLayout;
409-
this.axesOptions.merge(fullSceneLayout);
409+
this.axesOptions.merge(fullLayout, fullSceneLayout);
410410
this.spikeOptions.merge(fullSceneLayout);
411411

412412
// Update camera and camera mode

0 commit comments

Comments
 (0)