Skip to content

Commit 7b302d3

Browse files
committed
fix to revert ribbons
1 parent 088a2c7 commit 7b302d3

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/traces/surface/convert.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ proto.handlePick = function(selection) {
7373
var xRatio = (selection.data.index[0] - 1) / this.dataScaleX - 1;
7474
var yRatio = (selection.data.index[1] - 1) / this.dataScaleY - 1;
7575

76-
var j = Math.max(Math.min(Math.round(xRatio), this.data._xlength - 1), 0);
76+
var j = Math.max(Math.min(Math.round(xRatio), this.data.z[0].length - 1), 0);
7777
var k = Math.max(Math.min(Math.round(yRatio), this.data._ylength - 1), 0);
7878

7979
selection.index = [j, k];
@@ -224,12 +224,18 @@ proto.calcXnums = function(xlen) {
224224
);
225225
var nums = [];
226226
for(var i = 1; i < xlen; i++) {
227-
nums[i - 1] = Math.round(
228-
maxDist / Math.abs(
229-
this.getXat(i, 0) -
230-
this.getXat(i - 1, 0)
231-
)
232-
);
227+
var a = this.getXat(i - 1, 0);
228+
var b = this.getXat(i, 0);
229+
230+
if(a !== undefined && a !== null &&
231+
b !== undefined && b !== null &&
232+
b != a) {
233+
nums[i - 1] = Math.round(
234+
maxDist / Math.abs(b - a)
235+
);
236+
} else {
237+
nums[i - 1] = 1;
238+
}
233239
}
234240
return nums;
235241
};
@@ -241,12 +247,18 @@ proto.calcYnums = function(ylen) {
241247
);
242248
var nums = [];
243249
for(var i = 1; i < ylen; i++) {
244-
nums[i - 1] = Math.round(
245-
maxDist / Math.abs(
246-
this.getYat(0, i) -
247-
this.getYat(0, i - 1)
248-
)
249-
);
250+
var a = this.getYat(0, i - 1);
251+
var b = this.getYat(0, i);
252+
253+
if(a !== undefined && a !== null &&
254+
b !== undefined && b !== null &&
255+
b != a) {
256+
nums[i - 1] = Math.round(
257+
maxDist / Math.abs(b - a)
258+
);
259+
} else {
260+
nums[i - 1] = 1;
261+
}
250262
}
251263
return nums;
252264
};
@@ -346,7 +358,7 @@ proto.update = function(data) {
346358
alpha = data.opacity,
347359
colormap = parseColorScale(data.colorscale, alpha),
348360
scaleFactor = scene.dataScale,
349-
xlen = data._xlength,
361+
xlen = data.z[0].length,
350362
ylen = data._ylength,
351363
contourLevels = scene.contourLevels;
352364

0 commit comments

Comments
 (0)