-
-
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 all 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,119 @@ | ||
/** | ||
* 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(' ') | ||
}, | ||
|
||
values: { | ||
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(' ') | ||
}, | ||
|
||
vmin: { | ||
valType: 'number', | ||
role: 'info', | ||
editType: 'calc', | ||
description: 'Sets the minimum intensity bound of the volume. Defaults to the smallest value in values.' | ||
}, | ||
|
||
vmax: { | ||
valType: 'number', | ||
role: 'info', | ||
editType: 'calc', | ||
description: 'Sets the maximum intensity bound of the volume. Defaults to the largest value in values.' | ||
}, | ||
|
||
cmin: { | ||
valType: 'number', | ||
role: 'info', | ||
editType: 'calc', | ||
description: 'Sets the colorscale start intensity of the volume. Defaults to the smallest value in values.' | ||
}, | ||
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.
|
||
|
||
cmax: { | ||
valType: 'number', | ||
role: 'info', | ||
editType: 'calc', | ||
description: 'Sets the colorscale end intensity of the volume. Defaults to the largest value in values.' | ||
}, | ||
|
||
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]; | ||
}); | ||
|
||
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 values = trace.values; | ||
var len = values.length; | ||
var vMax = -Infinity; | ||
var vMin = Infinity; | ||
|
||
for(var i = 0; i < len; i++) { | ||
var v = values[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.
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.