Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume traces #2753

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6a9c27b
initial scaffolding for volume trace
kig Jun 23, 2018
31fbc97
volume convert, pass gl to volume generator
kig Jun 23, 2018
d3fc93f
volume attributes tweaks, something renders
kig Jun 25, 2018
9e8378d
volume trace rendering sort of works, automatic default isoBounds
kig Jun 25, 2018
0691672
volume: add opacityscale param
kig Jun 25, 2018
a48ee0e
fix volume update, cooler example function
kig Jun 25, 2018
27e6334
Merge branch 'master' into volume-traces
etpinard Jul 11, 2018
e0d7fa1
add gl-volume3d (w/ updated deps) to package-lock
etpinard Jul 11, 2018
bbaaebb
use 'value' instead of 'u'
etpinard Jul 11, 2018
c392a7d
add gl-volume3d npm package
kig Aug 27, 2018
d7ae2fd
add volume to lib/index-gl3d.js
kig Aug 27, 2018
ce212cb
createvolumeTrace -> createVolumeTrace
kig Aug 27, 2018
6866c18
volume trace hover text scaffolding
kig Sep 10, 2018
379efe6
add roles to volume attributes
kig Sep 10, 2018
61b9f60
Merge branch 'master' into volume-traces
kig Sep 10, 2018
34a1aa7
volume lint fixes
kig Sep 13, 2018
4f11e35
volume: remove boundmin/max, use default opacity, describe opacitymap…
kig Sep 13, 2018
0b06423
fix lint issue
kig Sep 20, 2018
34b40f0
volume/convert.js: bring back trace.opacity
kig Sep 20, 2018
4c6f59c
volume: document vmin, vmax, cmin, cmax, rename value to values
kig Sep 28, 2018
d788250
volume plot tests, initial scaffold
kig Oct 3, 2018
7107b68
Merge branch 'master' into volume-traces
etpinard Oct 29, 2018
8f93b02
bump gl-volume3d to kig's latest
etpinard Oct 29, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/index-gl3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Plotly.register([
require('./surface'),
require('./mesh3d'),
require('./cone'),
require('./streamtube')
require('./streamtube'),
require('./volume')
]);

module.exports = Plotly;
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Plotly.register([
require('./mesh3d'),
require('./cone'),
require('./streamtube'),
require('./volume'),

require('./scattergeo'),
require('./choropleth'),
Expand Down
11 changes: 11 additions & 0 deletions lib/volume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = require('../src/traces/volume');
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"gl-select-box": "^1.0.2",
"gl-spikes2d": "^1.0.1",
"gl-streamtube3d": "^1.0.0",
"gl-volume3d": "^0.5.0",
"gl-surface3d": "^1.3.5",
"glslify": "^6.2.1",
"has-hover": "^1.0.1",
Expand Down
111 changes: 111 additions & 0 deletions src/traces/volume/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var colorscaleAttrs = require('../../components/colorscale/attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');
var mesh3dAttrs = require('../mesh3d/attributes');
var baseAttrs = require('../../plots/attributes');

var extendFlat = require('../../lib/extend').extendFlat;

var attrs = {
x: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the x coordinates of the volume'
].join(' ')
},
y: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the y coordinates of the volume'
].join(' ')
},
z: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the z coordinates of the volume'
].join(' ')
},

value: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed this in a couple months ago, but thinking about this again, I think values (n.b. plural) would be better. It would match values attributes in pie, splom and parcoords traces.

valType: 'data_array',
role: 'info',
editType: 'calc',
description: 'Sets the intensity values of the volume.'
},

opacityscale: {
valType: 'data_array',
role: 'info',
editType: 'calc',
description: [
'Sets the opacity scale of the volume.',
'Defines which opacity to use for which intensity.',
'Multiplied with trace.opacity to obtain the final opacity.',
'Colorscale-like array of [[0, opacity0], [v1, opacity1], ..., [1, opacityN]].'
].join(' ')
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this mapping over the same range as colorscale? If so, can we specify it similarly, as a piecewise-linear list of pairs [[0, opacity0], [v1, opacity1], ..., [1, opacityN]]?

Is this used along with trace.opacity? Like the two are multiplied together perhaps? However that works it should be in the description.


imin: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget. Did we settle on imin / imax in the past? If not, I think I would prefer vmin and vmax to match the v in values.

We should also explain how this pair of attributes is related to cmin / cmax

    volumeOpts.isoBounds = [trace.cmin, trace.cmax];
    volumeOpts.intensityBounds = [
        trace.imin === undefined ? trace.cmin : trace.imin,
        trace.imax === undefined ? trace.cmax : trace.imax
    ];

in the attribute description.

valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the minimum intensity bound of the volume.'
},

imax: {
valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the maximum intensity bound of the volume.'
},

text: {
valType: 'string',
role: 'info',
dflt: '',
arrayOk: true,
editType: 'calc',
description: [
'Sets the text elements associated with the volume points.',
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
'these elements will be seen in the hover labels.'
].join(' ')
}
};

extendFlat(attrs, colorscaleAttrs('', {
colorAttr: 'value',
showScaleDflt: true,
editTypeOverride: 'calc'
}), {
colorbar: colorbarAttrs
});

var fromMesh3d = ['opacity', 'lightposition', 'lighting'];

fromMesh3d.forEach(function(k) {
attrs[k] = mesh3dAttrs[k];
});

attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {
editType: 'calc',
flags: ['x', 'y', 'z', 'intensity', 'text', 'name'],
dflt: 'x+y+z+intensity+text+name'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove hoverinfo completely, as we're not implementing a hover handler in this first iteration.

});

module.exports = attrs;
27 changes: 27 additions & 0 deletions src/traces/volume/calc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var colorscaleCalc = require('../../components/colorscale/calc');

module.exports = function calc(gd, trace) {
var value = trace.value;
var len = value.length;
var vMax = -Infinity;
var vMin = Infinity;

for(var i = 0; i < len; i++) {
var v = value[i];
vMax = Math.max(vMax, v);
vMin = Math.min(vMin, v);
}

trace._vMax = vMax;
colorscaleCalc(trace, [vMin, vMax], '', 'c');
};
Loading