Skip to content

Commit 2d7adee

Browse files
committed
mock and fix for surface plot with empty z array
required minimum 2x2 data for a surface revised conditions for z correct z length check new baseline added
1 parent 0078626 commit 2d7adee

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

src/traces/surface/defaults.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2323
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
2424
}
2525

26+
var x = coerce('x');
27+
var y = coerce('y');
28+
2629
var z = coerce('z');
27-
if(!z) {
30+
if(!z || !z.length ||
31+
(x ? (x.length < 2) : false) ||
32+
(y ? (y.length < 2) : false)
33+
) {
2834
traceOut.visible = false;
2935
return;
3036
}
3137

32-
var x = coerce('x');
33-
coerce('y');
3438

3539
traceOut._xlength = (Array.isArray(x) && Lib.isArrayOrTypedArray(x[0])) ? z.length : z[0].length;
3640
traceOut._ylength = z.length;
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"data": [
3+
{
4+
"type": "surface",
5+
"x": [],
6+
"y": [],
7+
"z": []
8+
},
9+
{
10+
"type": "surface",
11+
"x": [0],
12+
"y": [0],
13+
"z": [[1]]
14+
},
15+
{
16+
"type": "surface",
17+
"x": [0, 1, 2],
18+
"y": [0],
19+
"z": [[1, 2, 3]]
20+
},
21+
{
22+
"type": "surface",
23+
"x": [0],
24+
"y": [0, 1, 2],
25+
"z": [[1, 2, 3]]
26+
}
27+
],
28+
"layout": {
29+
"title": "Surface traces with rows/columns less than two<br>or with no Z data would be invisible.",
30+
"width": 600,
31+
"height": 400
32+
}
33+
}

0 commit comments

Comments
 (0)