-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Shared color axes #3803
Shared color axes #3803
Conversation
- adapt multiple trace attributes.js files accordingly - standard colorscale/attributes import to colorScaleAttrs
- 'line' is now declared within _module.colorbar, so we don't need this block - add scatter3d test for good measure
- reuse Colorscale.supplyDefaults - use 'cmin', 'cmax' and 'cauto' no matter the trace types plotted - keep track of color axes referenced in the traces in fullLayout._colorAxes - ignore coloraxis referenced when colorbar visuals are incompatible - tweak PlotSchema.get() for layout.colorscale / layout.coloraxis? edge cases
... to help with per-trace min/max/auto or per-coloraxis defs
... and add makeColorScaleFuncFromTrace wrapper to DRY things up a little bit.
- use min of min (and max of max) of all traces linked to same color axis to compute min/max when auto:true - call Colorscale.crossTraceDefaults after having relinked layout, to use coloraxis._min, coloraxis._max -
- which has special logic which currently mutates zmin/zmax after the calc step.
- remove zmin/zmax mutations happening after the calc stpe - make traceIs('contour') traces call Colorscale.calc with their own options.
@@ -90,7 +91,7 @@ function makeColorBarData(gd) { | |||
|
|||
if(cont && cont.showscale) { | |||
var opts = cont.colorbar; | |||
opts._id = 'cb' + trace.uid; | |||
opts._id = 'cb' + trace.uid + (allowsMultiplotCbs && contName ? '-' + contName : ''); |
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.
This commits essentially resolves #3555
I didn't add support for marker.line.
colorbars (yet) - let me know you think that's a good idea.
} else { | ||
// re-coerce colorscale attributes w/o coloraxis | ||
for(var i = 0; i < stash[2].length; i++) { | ||
stash[2][i](); |
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.
As per @alexcjohnson 's #3431 (comment)
|
||
var cAttrs = ['cauto', 'colorscale', 'reversescale']; | ||
cAttrs.forEach(function(attr) { | ||
expect(fullLayout.coloraxis[attr]).not.toBe(undefined, 'coloraxis ' + attr); |
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.
Please note that layout.coloraxis?
use cmin
, cmax
and cauto
no matter which trace types make reference to them. In other words, setting zmin
or zmax
in a coloraxis won't do anything.
if(min === undefined) { | ||
min = minVal(); | ||
} else if(auto) { | ||
if(container._colorAx && isNumeric(min)) { |
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.
This is how we get all traces sharing the same coloraxis to contribute to the auto cmin
/ cmax
computations.
Wondering could we apply this on |
We could. But as mentioned in #3803 (comment) - I'm not 100% sure adding colorbar to Edit: I misread your comment. Here's an example: https://codepen.io/etpinard/pen/bJOLam?editors=0010 |
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.
Great!
@etpinard please find my questions below.
Also it would be nice to add a new gl3d mock or edit gl3d_ribbons.
Thanks.
Thanks for the tip @archmoj . It turns out gl3d needed a bit more work than anticipated. See 1d4d06f |
Awesome PR. |
resolves #3431 - to be merged in #3786
@plotly/plotly_js please review this PR commit-by-commit. The "main" commits are:
layout.coloraxis?
attribute declarations and default logic are added.contour
trace edge cases.