Skip to content

Commit fcd460d

Browse files
committed
fix for hover on interpolated z values
1 parent 0481395 commit fcd460d

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/traces/surface/convert.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function SurfaceTrace(scene, surface, uid) {
3333
this.dataScaleX = 1.0;
3434
this.dataScaleY = 1.0;
3535
this.refineData = true;
36+
this._interpolatedZ = false;
3637
}
3738

3839
var proto = SurfaceTrace.prototype;
@@ -62,9 +63,11 @@ proto.getYat = function(a, b, calendar, axis) {
6263
};
6364

6465
proto.getZat = function(a, b, calendar, axis) {
65-
var v = (
66-
this.data.z[b][a]
67-
);
66+
var v = this.data.z[b][a];
67+
68+
if(v === null && this.data.connectgaps && this.data._interpolatedZ) {
69+
v = this.data._interpolatedZ[b][a];
70+
}
6871

6972
return (calendar === undefined) ? v : axis.d2l(v, 0, calendar);
7073
};
@@ -410,6 +413,14 @@ proto.update = function(data) {
410413
if(data.connectgaps) {
411414
data._emptypoints = findEmpties(rawCoords[2]);
412415
interp2d(rawCoords[2], data._emptypoints);
416+
417+
data._interpolatedZ = [];
418+
for(j = 0; j < xlen; j++) {
419+
data._interpolatedZ[j] = [];
420+
for(k = 0; k < ylen; k++) {
421+
data._interpolatedZ[j][k] = rawCoords[2][j][k];
422+
}
423+
}
413424
}
414425

415426
// Note: log axes are not defined in surfaces yet.
Loading

test/image/mocks/gl3d_surface_connectgaps.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
{
44
"type": "surface",
55
"connectgaps": true,
6-
"x": [0, 1, 2, 3],
6+
"x": [0, 1, 2, 3, 4],
77
"y": [0, 1, 2, 3],
88
"z": [
9-
[1, 1, 1, 1],
10-
[1, null, 2, null],
11-
[1, 1, 1, 1],
9+
[null, 2, 1, 1, 1],
10+
[2, 1, null, 2, null],
11+
[2, 1, 1, 1],
1212
[1, null, 0, null]
1313
]
1414
}
1515
],
1616
"layout": {
17-
"title": "Surface interpolate gaps",
17+
"title": "Surface plot with interpolated gaps<br>(connectgaps: true)",
1818
"width": 600,
1919
"height": 400
2020
}

0 commit comments

Comments
 (0)