Skip to content

Commit 8ae2d0e

Browse files
committedFeb 5, 2018
fix and lock hoverinfo restyle for gl3d traces
1 parent d14cdab commit 8ae2d0e

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed
 

‎src/traces/mesh3d/attributes.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ var colorAttrs = require('../../components/colorscale/color_attributes');
1212
var colorscaleAttrs = require('../../components/colorscale/attributes');
1313
var colorbarAttrs = require('../../components/colorbar/attributes');
1414
var surfaceAtts = require('../surface/attributes');
15+
var baseAttrs = require('../../plots/attributes');
1516

1617
var extendFlat = require('../../lib/extend').extendFlat;
1718

18-
1919
module.exports = extendFlat(colorAttrs('', 'calc', false), {
2020
x: {
2121
valType: 'data_array',
@@ -222,5 +222,7 @@ module.exports = extendFlat(colorAttrs('', 'calc', false), {
222222
description: 'Epsilon for face normals calculation avoids math issues arising from degenerate geometry.'
223223
},
224224
editType: 'calc'
225-
}, surfaceAtts.lighting)
225+
}, surfaceAtts.lighting),
226+
227+
hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {editType: 'calc'})
226228
});

‎src/traces/scatter3d/attributes.js

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var scatterAttrs = require('../scatter/attributes');
1212
var colorAttributes = require('../../components/colorscale/color_attributes');
1313
var errorBarAttrs = require('../../components/errorbars/attributes');
14+
var baseAttrs = require('../../plots/attributes');
1415
var DASHES = require('../../constants/gl3d_dashes');
1516

1617
var MARKER_SYMBOLS = require('../../constants/gl3d_markers');
@@ -171,6 +172,8 @@ var attrs = module.exports = overrideAll({
171172
error_x: errorBarAttrs,
172173
error_y: errorBarAttrs,
173174
error_z: errorBarAttrs,
175+
176+
hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {editType: 'calc'})
174177
}, 'calc', 'nested');
175178

176179
attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes';

‎src/traces/surface/attributes.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var Color = require('../../components/color');
1212
var colorscaleAttrs = require('../../components/colorscale/attributes');
1313
var colorbarAttrs = require('../../components/colorbar/attributes');
14+
var baseAttrs = require('../../plots/attributes');
1415

1516
var extendFlat = require('../../lib/extend').extendFlat;
1617
var overrideAll = require('../../plot_api/edit_types').overrideAll;
@@ -242,7 +243,9 @@ var attrs = module.exports = overrideAll({
242243
zmax: extendFlat({}, colorscaleAttrs.zmax, {
243244
description: 'Obsolete. Use `cmax` instead.'
244245
})
245-
}
246+
},
247+
248+
hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {editType: 'calc'})
246249
}, 'calc', 'nested');
247250

248251
attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes';

‎test/jasmine/tests/gl3d_plot_interact_test.js

+44-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ describe('Test gl3d plots', function() {
3636
var mock3 = require('@mocks/gl3d_autocolorscale');
3737

3838
function assertHoverText(xLabel, yLabel, zLabel, textLabel) {
39-
var content = [xLabel, yLabel, zLabel];
39+
var content = [];
40+
if(xLabel) content.push(xLabel);
41+
if(yLabel) content.push(yLabel);
42+
if(zLabel) content.push(zLabel);
4043
if(textLabel) content.push(textLabel);
4144
assertHoverLabelContent({nums: content.join('\n')});
4245
}
@@ -193,6 +196,16 @@ describe('Test gl3d plots', function() {
193196
.then(_hover)
194197
.then(function() {
195198
assertHoverText('x: 二 6, 2017', 'y: c', 'z: 100k', 'Clementine');
199+
200+
return Plotly.restyle(gd, 'hoverinfo', 'text');
201+
})
202+
.then(function() {
203+
assertHoverText(null, null, null, 'Clementine');
204+
205+
return Plotly.restyle(gd, 'hoverinfo', 'z');
206+
})
207+
.then(function() {
208+
assertHoverText(null, null, '100k');
196209
})
197210
.catch(fail)
198211
.then(done);
@@ -273,6 +286,18 @@ describe('Test gl3d plots', function() {
273286
'colorbar.tickvals': undefined,
274287
'colorbar.ticktext': undefined
275288
});
289+
290+
return Plotly.restyle(gd, 'hoverinfo', 'z');
291+
})
292+
.then(_hover)
293+
.then(function() {
294+
assertHoverText(null, null, '43');
295+
296+
return Plotly.restyle(gd, 'hoverinfo', 'text');
297+
})
298+
.then(_hover)
299+
.then(function() {
300+
assertHoverText(null, null, null, 'one two');
276301
})
277302
.then(done);
278303
});
@@ -334,6 +359,24 @@ describe('Test gl3d plots', function() {
334359
.then(function() {
335360
assertHoverText('x: 3', 'y: 4', 'z: 5', 'ts: 3\nhz: 4\nftt:5');
336361
})
362+
.then(function() {
363+
return Plotly.restyle(gd, 'hoverinfo', 'x+y');
364+
})
365+
.then(function() {
366+
assertHoverText('(3, 4)');
367+
})
368+
.then(function() {
369+
return Plotly.restyle(gd, 'hoverinfo', 'text');
370+
})
371+
.then(function() {
372+
assertHoverText('ts: 3\nhz: 4\nftt:5');
373+
})
374+
.then(function() {
375+
return Plotly.restyle(gd, 'text', 'yo!');
376+
})
377+
.then(function() {
378+
assertHoverText(null, null, null, 'yo!');
379+
})
337380
.catch(fail)
338381
.then(done);
339382
});

0 commit comments

Comments
 (0)
Please sign in to comment.