-
-
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
Merged
Merged
Shared color axes #3803
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c401f87
add support for marker AND line colorbars on same scatter3d graph
etpinard eb7fe0f
declare colorbar attrs within Colorscale.attributes()
etpinard 5e7ed27
remove obsolete 'line' relinkColorAttrs block
etpinard ae3f407
add 'coloraxis' layout attr and default logic
etpinard 3e5bec8
add Colorscale.extractOpts helpers
etpinard 8f1fde1
use extractOpts in extractScale
etpinard 5bb341e
implement crossTraceDefaults, calc and Colobar.draw for color axes
etpinard b6503ac
add 'colorbars' edit type to layout flags
etpinard fa67db3
make colorbar from color axes editable
etpinard eab822c
add baseline for contour traces w. coloring:heatmap & autocontours:false
etpinard bd81ac2
make contour zmin/zmax logic compatible with color axes
etpinard 49103b4
add shared color axes mocks
etpinard 1d4d06f
fix and :lock: coloraxis for gl3d traces
etpinard 29a92a6
rename outerCont -> parentCont + add jsDoc
etpinard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,37 +8,50 @@ | |
|
||
'use strict'; | ||
|
||
var isNumeric = require('fast-isnumeric'); | ||
|
||
var Lib = require('../../lib'); | ||
var extractOpts = require('./helpers').extractOpts; | ||
|
||
module.exports = function calc(gd, trace, opts) { | ||
var fullLayout = gd._fullLayout; | ||
var vals = opts.vals; | ||
var containerStr = opts.containerStr; | ||
var cLetter = opts.cLetter; | ||
|
||
var container = containerStr ? | ||
Lib.nestedProperty(trace, containerStr).get() : | ||
trace; | ||
|
||
var autoAttr = cLetter + 'auto'; | ||
var minAttr = cLetter + 'min'; | ||
var maxAttr = cLetter + 'max'; | ||
var midAttr = cLetter + 'mid'; | ||
var auto = container[autoAttr]; | ||
var min = container[minAttr]; | ||
var max = container[maxAttr]; | ||
var mid = container[midAttr]; | ||
var scl = container.colorscale; | ||
var cOpts = extractOpts(container); | ||
var auto = cOpts.auto !== false; | ||
var min = cOpts.min; | ||
var max = cOpts.max; | ||
var mid = cOpts.mid; | ||
|
||
var minVal = function() { return Lib.aggNums(Math.min, null, vals); }; | ||
var maxVal = function() { return Lib.aggNums(Math.max, null, vals); }; | ||
|
||
if(auto !== false || min === undefined) { | ||
min = Lib.aggNums(Math.min, null, vals); | ||
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 commentThe 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 |
||
min = Math.min(min, minVal()); | ||
} else { | ||
min = minVal(); | ||
} | ||
} | ||
|
||
if(auto !== false || max === undefined) { | ||
max = Lib.aggNums(Math.max, null, vals); | ||
if(max === undefined) { | ||
max = maxVal(); | ||
} else if(auto) { | ||
if(container._colorAx && isNumeric(max)) { | ||
max = Math.max(max, maxVal()); | ||
} else { | ||
max = maxVal(); | ||
} | ||
} | ||
|
||
if(auto !== false && mid !== undefined) { | ||
if(auto && mid !== undefined) { | ||
if(max - mid > mid - min) { | ||
min = mid - (max - mid); | ||
} else if(max - mid < mid - min) { | ||
|
@@ -51,14 +64,14 @@ module.exports = function calc(gd, trace, opts) { | |
max += 0.5; | ||
} | ||
|
||
container['_' + minAttr] = container[minAttr] = min; | ||
container['_' + maxAttr] = container[maxAttr] = max; | ||
cOpts._sync('min', min); | ||
cOpts._sync('max', max); | ||
|
||
if(container.autocolorscale) { | ||
if(cOpts.autocolorscale) { | ||
var scl; | ||
if(min * max < 0) scl = fullLayout.colorscale.diverging; | ||
else if(min >= 0) scl = fullLayout.colorscale.sequential; | ||
else scl = fullLayout.colorscale.sequentialminus; | ||
|
||
container._colorscale = container.colorscale = scl; | ||
cOpts._sync('colorscale', scl); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.