Skip to content

Commit 5a42de0

Browse files
committed
comment out cones.(x|y|z) attributes for now
1 parent b7465fb commit 5a42de0

File tree

6 files changed

+63
-5153
lines changed

6 files changed

+63
-5153
lines changed

src/traces/cone/attributes.js

+47-39
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ var attrs = {
2323
editType: 'calc+clearAxisTypes',
2424
description: [
2525
'Sets the x coordinates of the vector field',
26-
'If `cones` positions are not provided, this array',
27-
'corresponds to the x coordinates of the cones displayed as well.'
26+
'and of the displayed cones.'
2827
].join(' ')
2928
},
3029
y: {
@@ -33,8 +32,7 @@ var attrs = {
3332
editType: 'calc+clearAxisTypes',
3433
description: [
3534
'Sets the y coordinates of the vector field',
36-
'If `cones` positions are not provided, this array',
37-
'corresponds to the y coordinates of the cones displayed as well.'
35+
'and of the displayed cones.'
3836
].join(' ')
3937
},
4038
z: {
@@ -43,8 +41,7 @@ var attrs = {
4341
editType: 'calc+clearAxisTypes',
4442
description: [
4543
'Sets the z coordinates of the vector field',
46-
'If `cones` positions are not provided, this array',
47-
'corresponds to the z coordinates of the cones displayed as well.'
44+
'and of the displayed cones.'
4845
].join(' ')
4946
},
5047

@@ -64,38 +61,49 @@ var attrs = {
6461
description: 'Sets the z components of the vector field.'
6562
},
6663

67-
cones: {
68-
// potential attributes to add:
69-
//
70-
// - meshmode: 'cartesian-product', 'pts', 'grid'
71-
//
72-
// under `meshmode: 'grid'`
73-
// - (x|y|z)grid.start
74-
// - (x|y|z)grid.end
75-
// - (x|y|z)grid.size
76-
77-
x: {
78-
valType: 'data_array',
79-
editType: 'calc',
80-
description: 'Sets the x coordinates of the cones to be displayed.'
81-
},
82-
y: {
83-
valType: 'data_array',
84-
editType: 'calc',
85-
description: 'Sets the y coordinates of the cones to be displayed.'
86-
},
87-
z: {
88-
valType: 'data_array',
89-
editType: 'calc',
90-
description: 'Sets the z coordinates of the cones to be displayed.'
91-
},
92-
93-
editType: 'calc',
94-
description: [
95-
'By setting `cones.x`, `cones.y` and `cones.z` to 1D arrays,',
96-
'plotly creates a mesh using the cartesian product of those 3 arrays.'
97-
].join(' ')
98-
},
64+
// TODO add way to specify cone positions independently of the vector field
65+
// provided, similar to MATLAB's coneplot Cx/Cy/Cz meshgrids,
66+
// see https://www.mathworks.com/help/matlab/ref/coneplot.html
67+
//
68+
// Alternatively, if our goal is only to 'fill in gaps' in the vector data,
69+
// we could try to extend the heatmap 'connectgaps' algorithm to 3D.
70+
// From AJ: this particular algorithm which amounts to a Poisson equation,
71+
// both for interpolation and extrapolation - is the right one to use for
72+
// cones too. It makes a field with zero divergence, which is a good
73+
// baseline assumption for vector fields.
74+
//
75+
// cones: {
76+
// // potential attributes to add:
77+
// //
78+
// // - meshmode: 'cartesian-product', 'pts', 'grid'
79+
// //
80+
// // under `meshmode: 'grid'`
81+
// // - (x|y|z)grid.start
82+
// // - (x|y|z)grid.end
83+
// // - (x|y|z)grid.size
84+
//
85+
// x: {
86+
// valType: 'data_array',
87+
// editType: 'calc',
88+
// description: 'Sets the x coordinates of the cones to be displayed.'
89+
// },
90+
// y: {
91+
// valType: 'data_array',
92+
// editType: 'calc',
93+
// description: 'Sets the y coordinates of the cones to be displayed.'
94+
// },
95+
// z: {
96+
// valType: 'data_array',
97+
// editType: 'calc',
98+
// description: 'Sets the z coordinates of the cones to be displayed.'
99+
// },
100+
//
101+
// editType: 'calc',
102+
// description: [
103+
// 'By setting `cones.x`, `cones.y` and `cones.z` to 1D arrays,',
104+
// 'plotly creates a mesh using the cartesian product of those 3 arrays.'
105+
// ].join(' ')
106+
// },
99107

100108
sizemode: {
101109
valType: 'enumerated',
@@ -128,7 +136,7 @@ var attrs = {
128136
dflt: 'cm',
129137
description: [
130138
'Sets the cones\' anchor with respect to their x/y/z positions.',
131-
'Note that *cm* denote the cone\'s center of mass with corresponds to',
139+
'Note that *cm* denote the cone\'s center of mass which corresponds to',
132140
'1/4 from the tail to tip.'
133141
].join(' ')
134142
},

src/traces/cone/convert.js

+13-21
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ var proto = Cone.prototype;
2828
proto.handlePick = function(selection) {
2929
if(selection.object === this.pts) {
3030
var selectIndex = selection.index = selection.data.index;
31-
var dataScale = this.scene.dataScale;
32-
var xx = this._positions[selectIndex][0] / dataScale[0];
33-
var yy = this._positions[selectIndex][1] / dataScale[1];
34-
var zz = this._positions[selectIndex][2] / dataScale[2];
35-
var uu = this._vectors[selectIndex][0] / dataScale[0];
36-
var vv = this._vectors[selectIndex][1] / dataScale[1];
37-
var ww = this._vectors[selectIndex][2] / dataScale[2];
31+
var xx = this.data.x[selectIndex];
32+
var yy = this.data.y[selectIndex];
33+
var zz = this.data.z[selectIndex];
34+
var uu = this.data.u[selectIndex];
35+
var vv = this.data.v[selectIndex];
36+
var ww = this.data.w[selectIndex];
3837

3938
selection.traceCoordinate = [
4039
xx, yy, zz,
@@ -88,21 +87,18 @@ function convert(scene, trace) {
8887
toDataCoords(trace.z, 'zaxis')
8988
);
9089

91-
if(trace.cones && trace.cones.x && trace.cones.y && trace.cones.z) {
92-
coneOpts.meshgrid = [
93-
toDataCoords(trace.cones.x, 'xaxis'),
94-
toDataCoords(trace.cones.y, 'yaxis'),
95-
toDataCoords(trace.cones.z, 'zaxis')
96-
];
97-
}
98-
9990
coneOpts.colormap = parseColorScale(trace.colorscale);
10091
coneOpts.vertexIntensityBounds = [trace.cmin / trace._normMax, trace.cmax / trace._normMax];
10192

10293
coneOpts[sizeMode2sizeKey[trace.sizemode]] = trace.sizeref;
10394
coneOpts.coneOffset = anchor2coneOffset[trace.anchor];
10495

105-
return conePlot(coneOpts);
96+
var meshData = conePlot(coneOpts);
97+
98+
// stash positions for gl-scatter3d 'hover' trace
99+
meshData._pts = coneOpts.positions;
100+
101+
return meshData;
106102
}
107103

108104
proto.update = function(data) {
@@ -129,7 +125,7 @@ function createConeTrace(scene, data) {
129125

130126
var pts = createScatterPlot({
131127
gl: gl,
132-
position: meshData._positions,
128+
position: meshData._pts,
133129
project: false,
134130
opacity: 0
135131
});
@@ -141,10 +137,6 @@ function createConeTrace(scene, data) {
141137
mesh._trace = cone;
142138
pts._trace = cone;
143139

144-
// stash these for hover
145-
cone._positions = meshData._positions;
146-
cone._vectors = meshData._vectors;
147-
148140
scene.glplot.add(pts);
149141
scene.glplot.add(mesh);
150142

src/traces/cone/defaults.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3535
return;
3636
}
3737

38-
coerce('cones.x');
39-
coerce('cones.y');
40-
coerce('cones.z');
41-
4238
coerce('sizeref');
4339
coerce('sizemode');
4440

@@ -60,8 +56,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
6056

6157
coerce('text');
6258

63-
// disable 1D transforms
64-
// x/y/z and u/v/w should match lengths, cones.(x|y|z) should match as well, but
65-
// the two sets have different lengths so transforms wouldn't work.
59+
// disable 1D transforms (for now)
6660
traceOut._length = null;
6761
};

src/traces/cone/index.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ module.exports = {
2727
'Specify a vector field using 6 1D arrays,',
2828
'3 position arrays `x`, `y` and `z`',
2929
'and 3 vector component arrays `u`, `v`, `w`.',
30-
'',
31-
'If nothing else is provided, the cones are drawn exactly at the positions given',
32-
'by `x`, `y` and `z`.',
33-
'To specify the cone positions manually, use arrays attributes',
34-
'`cones.x`, `cones.y` and `cones.z`.'
30+
'The cones are drawn exactly at the positions given',
31+
'by `x`, `y` and `z`.'
3532
].join(' ')
3633
}
3734
};
-61.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)