-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Volume traces #2753
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
Changes from 19 commits
6a9c27b
31fbc97
d3fc93f
9e8378d
0691672
a48ee0e
27e6334
e0d7fa1
bbaaebb
c392a7d
d7ae2fd
ce212cb
6866c18
379efe6
61b9f60
34a1aa7
4f11e35
0b06423
34b40f0
4c6f59c
d788250
7107b68
8f93b02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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: { | ||
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(' ') | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this mapping over the same range as Is this used along with |
||
|
||
imin: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forget. Did we settle on We should also explain how this pair of attributes is related to 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 |
||
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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should remove |
||
}); | ||
|
||
module.exports = attrs; |
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'); | ||
}; |
There was a problem hiding this comment.
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 matchvalues
attributes in pie, splom and parcoords traces.