Skip to content

Commit bc8334b

Browse files
committed
applied distinctVals
1 parent c66a2bb commit bc8334b

20 files changed

+18
-73
lines changed

src/traces/isosurface/attributes.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,6 @@ function makeCapAttr(axLetter) {
8484
}
8585

8686
var attrs = module.exports = overrideAll(extendFlat({
87-
88-
width: {
89-
valType: 'integer',
90-
role: 'info',
91-
description: [
92-
'Sets the number of points on X axis.'
93-
].join(' ')
94-
},
95-
height: {
96-
valType: 'integer',
97-
role: 'info',
98-
description: [
99-
'Sets the number of points on Y axis.'
100-
].join(' ')
101-
},
102-
depth: {
103-
valType: 'integer',
104-
role: 'info',
105-
description: [
106-
'Sets the number of points on Z axis.'
107-
].join(' ')
108-
},
10987
x: {
11088
valType: 'data_array',
11189
role: 'info',

src/traces/isosurface/calc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ var colorscaleCalc = require('../../components/colorscale/calc');
1212

1313
module.exports = function calc(gd, trace) {
1414

15+
trace._len = Math.min(trace.x.length, trace.y.length, trace.z.length, trace.value.length);
16+
1517
var min = Infinity;
1618
var max = -Infinity;
1719
var len = trace.value.length;

src/traces/isosurface/convert.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ var createMesh = require('gl-mesh3d');
1414
var parseColorScale = require('../../lib/gl_format_color').parseColorScale;
1515
var str2RgbaArray = require('../../lib/str2rgbarray');
1616
var zip3 = require('../../plots/gl3d/zip3');
17+
var Lib = require('../../lib');
18+
19+
function distinctVals(col) {
20+
return Lib.distinctVals(col).vals;
21+
}
1722

1823
function IsosurfaceTrace(scene, mesh, uid) {
1924
this.scene = scene;
@@ -154,9 +159,13 @@ function generateIsosurfaceMesh(data) {
154159
var numVertices;
155160
var beginVertextLength;
156161

157-
var width = data.width;
158-
var height = data.height;
159-
var depth = data.depth;
162+
var Xs = distinctVals(data.x.slice(0, data._len));
163+
var Ys = distinctVals(data.y.slice(0, data._len));
164+
var Zs = distinctVals(data.z.slice(0, data._len));
165+
166+
var width = Xs.length;
167+
var height = Ys.length;
168+
var depth = Zs.length;
160169

161170
function getIndex(i, j, k) {
162171
return k + depth * j + depth * height * i;

src/traces/isosurface/defaults.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,16 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3030
traceOut.isomax = null;
3131
}
3232

33-
var width = coerce('width');
34-
var height = coerce('height');
35-
var depth = coerce('depth');
36-
var numVertices = width * height * depth;
37-
3833
var x = coerce('x');
3934
var y = coerce('y');
4035
var z = coerce('z');
4136
var value = coerce('value');
4237

4338
if(
44-
!x || !x.length || x.length !== numVertices ||
45-
!y || !y.length || y.length !== numVertices ||
46-
!z || !z.length || z.length !== numVertices ||
47-
!value || !value.length || value.length !== numVertices
39+
!x || !x.length ||
40+
!y || !y.length ||
41+
!z || !z.length ||
42+
!value || !value.length
4843
) {
4944
traceOut.visible = false;
5045
return;
-218 Bytes
Loading
-882 Bytes
Loading
273 Bytes
Loading
-714 Bytes
Loading

test/image/mocks/gl3d_isosurface_1single-surface_middle-range.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
"show": false,
2020
"width": 4
2121
},
22-
"width": 25,
23-
"height": 25,
24-
"depth": 25,
2522
"isomin": 250,
2623
"isomax": 1250,
2724
"value": [

test/image/mocks/gl3d_isosurface_2surfaces-checker_spaceframe.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
"show": false,
2020
"width": 4
2121
},
22-
"width": 25,
23-
"height": 25,
24-
"depth": 25,
2522
"isomin": 250,
2623
"isomax": 1250,
2724
"value": [

0 commit comments

Comments
 (0)