@@ -16,29 +16,34 @@ var colorbarDefaults = require('../colorbar/defaults');
1616
1717var isValidScale = require ( './scales' ) . isValid ;
1818
19- module . exports = function colorScaleDefaults ( traceIn , traceOut , layout , coerce , opts ) {
20- var prefix = opts . prefix ,
21- cLetter = opts . cLetter ,
22- containerStr = prefix . slice ( 0 , prefix . length - 1 ) ,
23- containerIn = prefix ?
24- Lib . nestedProperty ( traceIn , containerStr ) . get ( ) || { } :
25- traceIn ,
26- containerOut = prefix ?
27- Lib . nestedProperty ( traceOut , containerStr ) . get ( ) || { } :
28- traceOut ,
29- minIn = containerIn [ cLetter + 'min' ] ,
30- maxIn = containerIn [ cLetter + 'max' ] ,
31- sclIn = containerIn . colorscale ;
19+ function npMaybe ( cont , prefix ) {
20+ var containerStr = prefix . slice ( 0 , prefix . length - 1 ) ;
21+ return prefix ?
22+ Lib . nestedProperty ( cont , containerStr ) . get ( ) || { } :
23+ cont ;
24+ }
3225
26+ module . exports = function colorScaleDefaults ( traceIn , traceOut , layout , coerce , opts ) {
27+ var prefix = opts . prefix ;
28+ var cLetter = opts . cLetter ;
29+ var containerIn = npMaybe ( traceIn , prefix ) ;
30+ var containerOut = npMaybe ( traceOut , prefix ) ;
31+ var template = npMaybe ( traceOut . _template || { } , prefix ) || { } ;
32+
33+ var minIn = containerIn [ cLetter + 'min' ] ;
34+ var maxIn = containerIn [ cLetter + 'max' ] ;
3335 var validMinMax = isNumeric ( minIn ) && isNumeric ( maxIn ) && ( minIn < maxIn ) ;
3436 coerce ( prefix + cLetter + 'auto' , ! validMinMax ) ;
3537 coerce ( prefix + cLetter + 'min' ) ;
3638 coerce ( prefix + cLetter + 'max' ) ;
3739
3840 // handles both the trace case (autocolorscale is false by default) and
3941 // the marker and marker.line case (autocolorscale is true by default)
42+ var sclIn = containerIn . colorscale ;
43+ var sclTemplate = template . colorscale ;
4044 var autoColorscaleDflt ;
4145 if ( sclIn !== undefined ) autoColorscaleDflt = ! isValidScale ( sclIn ) ;
46+ if ( sclTemplate !== undefined ) autoColorscaleDflt = ! isValidScale ( sclTemplate ) ;
4247 coerce ( prefix + 'autocolorscale' , autoColorscaleDflt ) ;
4348
4449 coerce ( prefix + 'colorscale' ) ;
0 commit comments