Skip to content

Commit 0ae9c7f

Browse files
committed
add vector sizemode option to cone
1 parent baa752d commit 0ae9c7f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/traces/cone/attributes.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@ var attrs = {
9696

9797
sizemode: {
9898
valType: 'enumerated',
99-
values: ['scaled', 'absolute'],
99+
values: ['scaled', 'absolute', 'vector'],
100100
editType: 'calc',
101101
dflt: 'scaled',
102102
description: [
103103
'Determines whether `sizeref` is set as a *scaled* (i.e unitless) scalar',
104104
'(normalized by the max u/v/w norm in the vector field) or as',
105-
'*absolute* value (in the same units as the vector field).'
105+
'*absolute* value (in the same units as the vector field).',
106+
'To display sizes in actual vector scale use *vector*.'
106107
].join(' ')
107108
},
108109
sizeref: {
@@ -115,6 +116,7 @@ var attrs = {
115116
'This factor (computed internally) corresponds to the minimum "time" to travel across',
116117
'two successive x/y/z positions at the average velocity of those two successive positions.',
117118
'All cones in a given trace use the same factor.',
119+
'With `sizemode` set to *vector*, its default value is *1*',
118120
'With `sizemode` set to *scaled*, `sizeref` is unitless, its default value is *0.5*',
119121
'With `sizemode` set to *absolute*, `sizeref` has the same units as the u/v/w vector field,',
120122
'its the default value is half the sample\'s maximum vector norm.'

src/traces/cone/convert.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,20 @@ function convert(scene, trace) {
7979
coneOpts.vertexIntensityBounds = [cOpts.min / trace._normMax, cOpts.max / trace._normMax];
8080
coneOpts.coneOffset = anchor2coneOffset[trace.anchor];
8181

82-
if(trace.sizemode === 'scaled') {
82+
83+
var sizemode = trace.sizemode;
84+
if(sizemode === 'scaled') {
8385
// unitless sizeref
8486
coneOpts.coneSize = trace.sizeref || 0.5;
85-
} else {
87+
} else if(sizemode === 'absolute') {
8688
// sizeref here has unit of velocity
8789
coneOpts.coneSize = trace.sizeref && trace._normMax ?
8890
trace.sizeref / trace._normMax :
8991
0.5;
92+
} else if(sizemode === 'vector') {
93+
coneOpts.coneSize = trace.sizeref;
9094
}
95+
coneOpts.coneSizemode = sizemode;
9196

9297
var meshData = conePlot(coneOpts);
9398

src/traces/cone/defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2626
return;
2727
}
2828

29-
coerce('sizeref');
30-
coerce('sizemode');
29+
var sizemode = coerce('sizemode');
30+
coerce('sizeref', sizemode === 'vector' ? 1 : 0.5);
3131

3232
coerce('anchor');
3333

0 commit comments

Comments
 (0)