-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add optional intensity parameter for surfaces #314
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
Changes from 1 commit
93f1781
00109fd
52ab89c
4c4db95
cf23c09
7f1371e
d7a3fe1
e8b944d
70b31cc
78600b9
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 |
|---|---|---|
|
|
@@ -14,5 +14,9 @@ var colorscaleCalc = require('../../components/colorscale/calc'); | |
|
|
||
| // Compute auto-z and autocolorscale if applicable | ||
| module.exports = function calc(gd, trace) { | ||
| colorscaleCalc(trace, trace.z, '', 'z'); | ||
| if(trace.intensity) { | ||
| colorscaleCalc(trace, trace.intensity, '', 'intensity'); | ||
|
||
| } else { | ||
| colorscaleCalc(trace, trace.z, '', 'z'); | ||
|
||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,6 @@ var str2RgbaArray = require('../../lib/str2rgbarray'); | |
|
|
||
| var MIN_RESOLUTION = 128; | ||
|
|
||
|
|
||
| function SurfaceTrace(scene, surface, uid) { | ||
| this.scene = scene; | ||
| this.uid = uid; | ||
|
|
@@ -136,7 +135,7 @@ function refine(coords) { | |
| Math.floor((coords[0].shape[1]) * scaleF+1)|0 ]; | ||
| var nsize = nshape[0] * nshape[1]; | ||
|
|
||
| for(var i = 0; i < 3; ++i) { | ||
| for(var i = 0; i < coords.length; ++i) { | ||
| var padImg = padField(coords[i]); | ||
| var scaledImg = ndarray(new Float32Array(nsize), nshape); | ||
| homography(scaledImg, padImg, [scaleF, 0, 0, | ||
|
|
@@ -230,9 +229,6 @@ proto.update = function(data) { | |
| }); | ||
| } | ||
|
|
||
| //Refine if necessary | ||
| this.dataScale = refine(coords); | ||
|
|
||
| var params = { | ||
| colormap: colormap, | ||
| levels: [[], [], []], | ||
|
|
@@ -249,10 +245,30 @@ proto.update = function(data) { | |
| dynamicColor: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], | ||
| dynamicWidth: [1, 1, 1], | ||
| dynamicTint: [1, 1, 1], | ||
| opacity: 1, | ||
| colorBounds: [data.zmin * scaleFactor[2], data.zmax * scaleFactor[2]] | ||
| opacity: 1 | ||
| // TODO: Need to think about how to calculate this | ||
|
||
| /* | ||
| intensityBounds: [ | ||
| data.zmin * scaleFactor[2], | ||
| data.zmax * scaleFactor[2]] | ||
| */ | ||
|
||
| }; | ||
|
|
||
| //Refine if necessary | ||
| if('intensity' in data) { | ||
| var intensity = ndarray( | ||
| new Float32Array(xlen * ylen), [xlen, ylen]); | ||
| fill(intensity, function(row, col) { | ||
| return data.intensity[col][row]; | ||
| }); | ||
| coords.push(intensity); | ||
| } | ||
|
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. In order to preserve backward compatibility, we'll need to set the |
||
|
|
||
| this.dataScale = refine(coords); | ||
|
|
||
| if('intensity' in data) { | ||
| params.intensity = coords.pop(); | ||
| } | ||
|
|
||
| if('opacity' in data) { | ||
| if(data.opacity < 1) { | ||
|
|
@@ -300,6 +316,8 @@ proto.update = function(data) { | |
| } | ||
|
|
||
| params.coords = coords; | ||
|
|
||
|
|
||
| surface.update(params); | ||
|
|
||
| surface.highlightEnable = highlightEnable; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,254 @@ | ||
| { | ||
| "data": [ | ||
| { | ||
| "z": [ | ||
| [ | ||
| 1, | ||
| 1, | ||
| 1, | ||
| 1, | ||
| 1, | ||
| 1, | ||
| 1, | ||
| 1, | ||
| 1, | ||
| 1 | ||
| ], | ||
| [ | ||
| 0.955336489125606, | ||
| 0.955336489125606, | ||
| 0.955336489125606, | ||
| 0.955336489125606, | ||
| 0.955336489125606, | ||
| 0.955336489125606, | ||
| 0.955336489125606, | ||
| 0.955336489125606, | ||
| 0.955336489125606, | ||
| 0.955336489125606 | ||
| ], | ||
| [ | ||
| 0.8253356149096783, | ||
| 0.8253356149096783, | ||
| 0.8253356149096783, | ||
| 0.8253356149096783, | ||
| 0.8253356149096783, | ||
| 0.8253356149096783, | ||
| 0.8253356149096783, | ||
| 0.8253356149096783, | ||
| 0.8253356149096783, | ||
| 0.8253356149096783 | ||
| ], | ||
| [ | ||
| 0.6216099682706645, | ||
| 0.6216099682706645, | ||
| 0.6216099682706645, | ||
| 0.6216099682706645, | ||
| 0.6216099682706645, | ||
| 0.6216099682706645, | ||
| 0.6216099682706645, | ||
| 0.6216099682706645, | ||
| 0.6216099682706645, | ||
| 0.6216099682706645 | ||
| ], | ||
| [ | ||
| 0.3623577544766736, | ||
| 0.3623577544766736, | ||
| 0.3623577544766736, | ||
| 0.3623577544766736, | ||
| 0.3623577544766736, | ||
| 0.3623577544766736, | ||
| 0.3623577544766736, | ||
| 0.3623577544766736, | ||
| 0.3623577544766736, | ||
| 0.3623577544766736 | ||
| ], | ||
| [ | ||
| 0.0707372016677029, | ||
| 0.0707372016677029, | ||
| 0.0707372016677029, | ||
| 0.0707372016677029, | ||
| 0.0707372016677029, | ||
| 0.0707372016677029, | ||
| 0.0707372016677029, | ||
| 0.0707372016677029, | ||
| 0.0707372016677029, | ||
| 0.0707372016677029 | ||
| ], | ||
| [ | ||
| -0.2272020946930869, | ||
| -0.2272020946930869, | ||
| -0.2272020946930869, | ||
| -0.2272020946930869, | ||
| -0.2272020946930869, | ||
| -0.2272020946930869, | ||
| -0.2272020946930869, | ||
| -0.2272020946930869, | ||
| -0.2272020946930869, | ||
| -0.2272020946930869 | ||
| ], | ||
| [ | ||
| -0.5048461045998576, | ||
| -0.5048461045998576, | ||
| -0.5048461045998576, | ||
| -0.5048461045998576, | ||
| -0.5048461045998576, | ||
| -0.5048461045998576, | ||
| -0.5048461045998576, | ||
| -0.5048461045998576, | ||
| -0.5048461045998576, | ||
| -0.5048461045998576 | ||
| ], | ||
| [ | ||
| -0.7373937155412454, | ||
| -0.7373937155412454, | ||
| -0.7373937155412454, | ||
| -0.7373937155412454, | ||
| -0.7373937155412454, | ||
| -0.7373937155412454, | ||
| -0.7373937155412454, | ||
| -0.7373937155412454, | ||
| -0.7373937155412454, | ||
| -0.7373937155412454 | ||
| ], | ||
| [ | ||
| -0.904072142017061, | ||
| -0.904072142017061, | ||
| -0.904072142017061, | ||
| -0.904072142017061, | ||
| -0.904072142017061, | ||
| -0.904072142017061, | ||
| -0.904072142017061, | ||
| -0.904072142017061, | ||
| -0.904072142017061, | ||
| -0.904072142017061 | ||
| ] | ||
| ], | ||
| "intensity": [ | ||
| [ | ||
| 10, | ||
| 9, | ||
| 8, | ||
| 7, | ||
| 6, | ||
| 5, | ||
| 6, | ||
| 7, | ||
| 8, | ||
| 9 | ||
| ], | ||
| [ | ||
| 9, | ||
| 8, | ||
| 7, | ||
| 6, | ||
| 5, | ||
| 4, | ||
| 5, | ||
| 6, | ||
| 7, | ||
| 8 | ||
| ], | ||
| [ | ||
| 8, | ||
| 7, | ||
| 6, | ||
| 5, | ||
| 4, | ||
| 3, | ||
| 4, | ||
| 5, | ||
| 6, | ||
| 7 | ||
| ], | ||
| [ | ||
| 7, | ||
| 6, | ||
| 5, | ||
| 4, | ||
| 3, | ||
| 2, | ||
| 3, | ||
| 4, | ||
| 5, | ||
| 6 | ||
| ], | ||
| [ | ||
| 6, | ||
| 5, | ||
| 4, | ||
| 3, | ||
| 2, | ||
| 1, | ||
| 2, | ||
| 3, | ||
| 4, | ||
| 5 | ||
| ], | ||
| [ | ||
| 5, | ||
| 4, | ||
| 3, | ||
| 2, | ||
| 1, | ||
| 0, | ||
| 1, | ||
| 2, | ||
| 3, | ||
| 4 | ||
| ], | ||
| [ | ||
| 6, | ||
| 5, | ||
| 4, | ||
| 3, | ||
| 2, | ||
| 1, | ||
| 2, | ||
| 3, | ||
| 4, | ||
| 5 | ||
| ], | ||
| [ | ||
| 7, | ||
| 6, | ||
| 5, | ||
| 4, | ||
| 3, | ||
| 2, | ||
| 3, | ||
| 4, | ||
| 5, | ||
| 6 | ||
| ], | ||
| [ | ||
| 8, | ||
| 7, | ||
| 6, | ||
| 5, | ||
| 4, | ||
| 3, | ||
| 4, | ||
| 5, | ||
| 6, | ||
| 7 | ||
| ], | ||
| [ | ||
| 9, | ||
| 8, | ||
| 7, | ||
| 6, | ||
| 5, | ||
| 4, | ||
| 5, | ||
| 6, | ||
| 7, | ||
| 8 | ||
| ] | ||
| ], | ||
| "type": "surface" | ||
| } | ||
| ], | ||
| "layout": { | ||
| "title": "Surface intensity test" | ||
| } | ||
| } |
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.
Ok, a couple things will need to happen here:
intensity->surfacecolorcauto,cminandcmax(which will take up the role ofzauto,zminandzmaxrespectively)zauto,zminandzmaxto the bottom of the attribute object in a_deprecatedblock (see example here)cleanData: