Skip to content

Commit afe36a6

Browse files
committed
fixup mock and added jasmine test to lock hover on an interpolated surface point
1 parent f0ac268 commit afe36a6

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed
-2.69 KB
Loading

test/image/mocks/gl3d_surface_connectgaps.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
{
44
"type": "surface",
55
"connectgaps": true,
6-
"x": [0, 1, 2, 3, 4],
7-
"y": [0, 1, 2, 3],
6+
"x": [0.1, 0.2, 0.3, 0.4],
7+
"y": [0, 1, 2, 3, 4],
88
"z": [
9-
[null, 2, 1, 1, 1],
10-
[2, 1, null, 2, null],
11-
[2, 1, 1, 1],
12-
[1, null, 0, null]
9+
[1001, 1002, 1001, null, null],
10+
[1002, 1001, null, 1002, null],
11+
[1002, null, 1001, 1001],
12+
[null, null, 1000, null]
1313
]
1414
}
1515
],

test/jasmine/tests/gl3d_plot_interact_test.js

+31
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,37 @@ describe('Test gl3d plots', function() {
378378
.then(done);
379379
});
380380

381+
it('@gl should display correct hover labels and emit correct event data (surface case with connectgaps enabled)', function(done) {
382+
var surfaceConnectgaps = require('@mocks/gl3d_surface_connectgaps');
383+
var _mock = Lib.extendDeep({}, surfaceConnectgaps);
384+
385+
function _hover() {
386+
mouseEvent('mouseover', 300, 200);
387+
return delay(20)();
388+
}
389+
390+
Plotly.plot(gd, _mock)
391+
.then(delay(20))
392+
.then(function() {
393+
gd.on('plotly_hover', function(eventData) {
394+
ptData = eventData.points[0];
395+
});
396+
})
397+
.then(_hover)
398+
.then(function() {
399+
assertHoverText('x: 0.2', 'y: 2', 'z: 1,001.25');
400+
assertEventData(0.2, 2, 1001.25, 0, [1, 2]);
401+
assertHoverLabelStyle(d3.selectAll('g.hovertext'), {
402+
bgcolor: 'rgb(68, 68, 68)',
403+
bordercolor: 'rgb(255, 255, 255)',
404+
fontSize: 13,
405+
fontFamily: 'Arial',
406+
fontColor: 'rgb(255, 255, 255)'
407+
}, 'initial');
408+
})
409+
.then(done);
410+
});
411+
381412
it('@gl should display correct hover labels and emit correct event data (surface case)', function(done) {
382413
var _mock = Lib.extendDeep({}, mock3);
383414

0 commit comments

Comments
 (0)