Skip to content

Commit 863b0da

Browse files
committed
implement 'sizemode' and 'sizeref'
1 parent 89eaf11 commit 863b0da

File tree

6 files changed

+37
-14
lines changed

6 files changed

+37
-14
lines changed

src/traces/cone/attributes.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,28 @@ var attrs = {
8080
description: 'Sets the z coordinates of the vector field mesh.'
8181
},
8282

83-
// TODO
84-
// sizemode: {},
85-
// sizeref: {},
83+
sizemode: {
84+
valType: 'enumerated',
85+
values: ['scaled', 'absolute'],
86+
role: 'info',
87+
editType: 'calc',
88+
dflt: 'scaled',
89+
description: [
90+
'Sets the mode by which the cones are sized.',
91+
'If *scaled*, `sizeref` scales such that the reference cone size',
92+
'for the maximum vector magnitude is 1.',
93+
'If *absolute*, `sizeref` scales such that the reference cone size',
94+
'for vector magnitude 1 is one grid unit.'
95+
].join(' ')
96+
},
97+
sizeref: {
98+
valType: 'number',
99+
role: 'info',
100+
editType: 'calc',
101+
min: 0,
102+
dflt: 1,
103+
description: 'Sets the cone size reference value.'
104+
},
86105

87106
text: {
88107
valType: 'string',

src/traces/cone/defaults.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3939
coerce('vy');
4040
coerce('vz');
4141

42-
coerce('text');
42+
coerce('sizeref');
43+
coerce('sizemode');
4344

4445
// TODO do these attributes work?
4546
coerce('lighting.ambient');
@@ -57,6 +58,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
5758
// ... and should we restrict cmin,cmax > 0 ???
5859
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'c'});
5960

61+
coerce('text');
62+
6063
// disable 1D transforms
6164
// x/y/z should match lengths, u/v/w and vx/vy/vz should match as well, but
6265
// the two sets have different lengths so transforms wouldn't work.

src/traces/cone/helpers.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function zip3(x, y, z) {
2121
}
2222

2323
var axisName2scaleIndex = {xaxis: 0, yaxis: 1, zaxis: 2};
24+
var sizeMode2sizeKey = {scaled: 'coneSize', absolute: 'absoluteConeSize'};
2425

2526
exports.cone2mesh = function cone2mesh(trace, sceneLayout, dataScale) {
2627
var coneOpts = {};
@@ -61,9 +62,7 @@ exports.cone2mesh = function cone2mesh(trace, sceneLayout, dataScale) {
6162
coneOpts.colormap = parseColorScale(trace.colorscale);
6263
coneOpts.vertexIntensityBounds = [trace.cmin, trace.cmax];
6364

64-
// sizemode:
65-
// sizeref,
66-
coneOpts.coneSize = 2;
65+
coneOpts[sizeMode2sizeKey[trace.sizemode]] = trace.sizeref;
6766

6867
return conePlot(coneOpts);
6968
};
-166 Bytes
Loading
-24 Bytes
Loading

test/image/mocks/gl3d_cone-simple.json

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
{
22
"data": [
3-
{
4-
"type": "scatter3d",
5-
"mode": "markers",
3+
{
4+
"type": "scatter3d",
5+
"mode": "markers",
66
"x": [1, 2, 3],
77
"y": [1, 2, 3],
88
"z": [1, 2, 3]
9-
},
9+
},
1010
{
1111
"type": "cone",
1212
"x": [1, 2, 3],
1313
"y": [1, 2, 3],
1414
"z": [1, 2, 3],
15-
"u": [0.1, 0, 0],
16-
"v": [0, 0.3, 0],
17-
"w": [0, 0, 0.2]
15+
"u": [1, 0, 0],
16+
"v": [0, 3, 0],
17+
"w": [0, 0, 2],
18+
"sizemode": "absolute",
19+
"sizeref": 2
1820
}
1921
],
2022
"layout": {

0 commit comments

Comments
 (0)