Skip to content

Commit

Permalink
implement 'sizemode' and 'sizeref'
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed May 16, 2018
1 parent 89eaf11 commit 863b0da
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 14 deletions.
25 changes: 22 additions & 3 deletions src/traces/cone/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,28 @@ var attrs = {
description: 'Sets the z coordinates of the vector field mesh.'
},

// TODO
// sizemode: {},
// sizeref: {},
sizemode: {
valType: 'enumerated',
values: ['scaled', 'absolute'],
role: 'info',
editType: 'calc',
dflt: 'scaled',
description: [
'Sets the mode by which the cones are sized.',
'If *scaled*, `sizeref` scales such that the reference cone size',
'for the maximum vector magnitude is 1.',
'If *absolute*, `sizeref` scales such that the reference cone size',
'for vector magnitude 1 is one grid unit.'
].join(' ')
},
sizeref: {
valType: 'number',
role: 'info',
editType: 'calc',
min: 0,
dflt: 1,
description: 'Sets the cone size reference value.'
},

text: {
valType: 'string',
Expand Down
5 changes: 4 additions & 1 deletion src/traces/cone/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
coerce('vy');
coerce('vz');

coerce('text');
coerce('sizeref');
coerce('sizemode');

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

coerce('text');

// disable 1D transforms
// x/y/z should match lengths, u/v/w and vx/vy/vz should match as well, but
// the two sets have different lengths so transforms wouldn't work.
Expand Down
5 changes: 2 additions & 3 deletions src/traces/cone/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function zip3(x, y, z) {
}

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

exports.cone2mesh = function cone2mesh(trace, sceneLayout, dataScale) {
var coneOpts = {};
Expand Down Expand Up @@ -61,9 +62,7 @@ exports.cone2mesh = function cone2mesh(trace, sceneLayout, dataScale) {
coneOpts.colormap = parseColorScale(trace.colorscale);
coneOpts.vertexIntensityBounds = [trace.cmin, trace.cmax];

// sizemode:
// sizeref,
coneOpts.coneSize = 2;
coneOpts[sizeMode2sizeKey[trace.sizemode]] = trace.sizeref;

return conePlot(coneOpts);
};
Binary file modified test/image/baselines/gl3d_cone-simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_cone-sparse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 9 additions & 7 deletions test/image/mocks/gl3d_cone-simple.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"data": [
{
"type": "scatter3d",
"mode": "markers",
{
"type": "scatter3d",
"mode": "markers",
"x": [1, 2, 3],
"y": [1, 2, 3],
"z": [1, 2, 3]
},
},
{
"type": "cone",
"x": [1, 2, 3],
"y": [1, 2, 3],
"z": [1, 2, 3],
"u": [0.1, 0, 0],
"v": [0, 0.3, 0],
"w": [0, 0, 0.2]
"u": [1, 0, 0],
"v": [0, 3, 0],
"w": [0, 0, 2],
"sizemode": "absolute",
"sizeref": 2
}
],
"layout": {
Expand Down

0 comments on commit 863b0da

Please sign in to comment.