-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3341 from plotly/colorscale-no-mutate
Don't mutate colorscale, cmin/cmax and zmin/zmax into user traces
- Loading branch information
Showing
57 changed files
with
950 additions
and
559 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* 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 Lib = require('../../lib'); | ||
var hasColorscale = require('./helpers').hasColorscale; | ||
|
||
module.exports = function crossTraceDefaults(fullData) { | ||
function replace(cont, k) { | ||
var val = cont['_' + k]; | ||
if(val !== undefined) { | ||
cont[k] = val; | ||
} | ||
} | ||
|
||
function relinkColorAtts(trace, cAttrs) { | ||
var cont = cAttrs.container ? | ||
Lib.nestedProperty(trace, cAttrs.container).get() : | ||
trace; | ||
|
||
if(cont) { | ||
var isAuto = cont.zauto || cont.cauto; | ||
var minAttr = cAttrs.min; | ||
var maxAttr = cAttrs.max; | ||
|
||
if(isAuto || cont[minAttr] === undefined) { | ||
replace(cont, minAttr); | ||
} | ||
if(isAuto || cont[maxAttr] === undefined) { | ||
replace(cont, maxAttr); | ||
} | ||
if(cont.autocolorscale) { | ||
replace(cont, 'colorscale'); | ||
} | ||
} | ||
} | ||
|
||
for(var i = 0; i < fullData.length; i++) { | ||
var trace = fullData[i]; | ||
var _module = trace._module; | ||
|
||
if(_module.colorbar) { | ||
relinkColorAtts(trace, _module.colorbar); | ||
} | ||
|
||
// TODO could generalize _module.colorscale and use it here? | ||
|
||
if(hasColorscale(trace, 'marker.line')) { | ||
relinkColorAtts(trace, { | ||
container: 'marker.line', | ||
min: 'cmin', | ||
max: 'cmax' | ||
}); | ||
} | ||
|
||
if(hasColorscale(trace, 'line')) { | ||
relinkColorAtts(trace, { | ||
container: 'line', | ||
min: 'cmin', | ||
max: 'cmax' | ||
}); | ||
} | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.