diff --git a/src/traces/cone/attributes.js b/src/traces/cone/attributes.js index 438c45e4435..104c2462452 100644 --- a/src/traces/cone/attributes.js +++ b/src/traces/cone/attributes.js @@ -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', diff --git a/src/traces/cone/defaults.js b/src/traces/cone/defaults.js index 342d10fc874..9f44361b387 100644 --- a/src/traces/cone/defaults.js +++ b/src/traces/cone/defaults.js @@ -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'); @@ -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. diff --git a/src/traces/cone/helpers.js b/src/traces/cone/helpers.js index 853d1314544..0b500e0663d 100644 --- a/src/traces/cone/helpers.js +++ b/src/traces/cone/helpers.js @@ -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 = {}; @@ -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); }; diff --git a/test/image/baselines/gl3d_cone-simple.png b/test/image/baselines/gl3d_cone-simple.png index 50683cfb6ca..cbf3d65d3ee 100644 Binary files a/test/image/baselines/gl3d_cone-simple.png and b/test/image/baselines/gl3d_cone-simple.png differ diff --git a/test/image/baselines/gl3d_cone-sparse.png b/test/image/baselines/gl3d_cone-sparse.png index 779a4846263..873f944bad8 100644 Binary files a/test/image/baselines/gl3d_cone-sparse.png and b/test/image/baselines/gl3d_cone-sparse.png differ diff --git a/test/image/mocks/gl3d_cone-simple.json b/test/image/mocks/gl3d_cone-simple.json index 0b1d089a989..d96cef6ff1a 100644 --- a/test/image/mocks/gl3d_cone-simple.json +++ b/test/image/mocks/gl3d_cone-simple.json @@ -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": {