@@ -664,31 +664,38 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa
664
664
// supplyDefault'd and inherited as *colors* instead of an actual null
665
665
// attribute which needs to be supplydefaulted by the individual
666
666
// expanded traces.
667
- plots . clearExpandedTraceDefaultColors = function ( expandedTraces ) {
668
- var colorAttrs , path , trace , i , j ;
667
+ plots . clearTraceDefaultColors = function ( trace ) {
668
+ var colorAttrs , path , i ;
669
669
670
- // A better check *might* be to explicitly check for a groupby transform
671
- if ( expandedTraces . length <= 1 ) return ;
672
-
673
- function locateExpandedTraceAttrs ( attr , attrName , attrs , level ) {
670
+ // This uses weird closure state in order to satisfy the linter rule
671
+ // that we can't create functions in a loop.
672
+ function locateColorAttrs ( attr , attrName , attrs , level ) {
674
673
path [ level ] = attrName ;
675
674
path . length = level + 1 ;
676
675
if ( attr . useExpandedTraceDefaultColor ) {
677
676
colorAttrs . push ( path . join ( '.' ) ) ;
678
677
}
679
678
}
680
679
681
- for ( i = 0 ; i < expandedTraces . length ; i ++ ) {
682
- trace = expandedTraces [ i ] ;
683
- colorAttrs = [ ] ;
684
- path = [ ] ;
680
+ path = [ ] ;
685
681
686
- if ( ! trace || ! trace . _module ) continue ;
682
+ // Get the cached colorAttrs:
683
+ colorAttrs = trace . _module . _colorAttrs ;
687
684
688
- PlotSchema . crawl ( trace . _module . attributes , locateExpandedTraceAttrs ) ;
685
+ // Or else compute and cache the colorAttrs on the module:
686
+ if ( ! colorAttrs ) {
687
+ trace . _module . _colorAttrs = colorAttrs = [ ] ;
688
+ PlotSchema . crawl (
689
+ trace . _module . attributes ,
690
+ locateColorAttrs
691
+ ) ;
692
+ }
689
693
690
- for ( j = 0 ; j < colorAttrs . length ; j ++ ) {
691
- Lib . nestedProperty ( trace , colorAttrs [ j ] ) . set ( null ) ;
694
+ for ( i = 0 ; i < colorAttrs . length ; i ++ ) {
695
+ var origprop = Lib . nestedProperty ( trace , '_input.' + colorAttrs [ i ] ) ;
696
+
697
+ if ( ! origprop . get ( ) ) {
698
+ Lib . nestedProperty ( trace , colorAttrs [ i ] ) . set ( null ) ;
692
699
}
693
700
}
694
701
} ;
@@ -728,11 +735,9 @@ plots.supplyDataDefaults = function(dataIn, dataOut, layout, fullLayout) {
728
735
if ( fullTrace . transforms && fullTrace . transforms . length ) {
729
736
var expandedTraces = applyTransforms ( fullTrace , dataOut , layout , fullLayout ) ;
730
737
731
- plots . clearExpandedTraceDefaultColors ( expandedTraces ) ;
732
-
733
738
for ( var j = 0 ; j < expandedTraces . length ; j ++ ) {
734
- var expandedTrace = expandedTraces [ j ] ,
735
- fullExpandedTrace = plots . supplyTraceDefaults ( expandedTrace , cnt , fullLayout , i ) ;
739
+ var expandedTrace = expandedTraces [ j ] ;
740
+ var fullExpandedTrace = plots . supplyTraceDefaults ( expandedTrace , cnt , fullLayout , i ) ;
736
741
737
742
// mutate uid here using parent uid and expanded index
738
743
// to promote consistency between update calls
0 commit comments