@@ -664,31 +664,38 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa
664664// supplyDefault'd and inherited as *colors* instead of an actual null
665665// attribute which needs to be supplydefaulted by the individual
666666// expanded traces.
667- plots . clearExpandedTraceDefaultColors = function ( expandedTraces ) {
668- var colorAttrs , path , trace , i , j ;
667+ plots . clearTraceDefaultColors = function ( trace ) {
668+ var colorAttrs , path , i ;
669669
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 ) {
674673 path [ level ] = attrName ;
675674 path . length = level + 1 ;
676675 if ( attr . useExpandedTraceDefaultColor ) {
677676 colorAttrs . push ( path . join ( '.' ) ) ;
678677 }
679678 }
680679
681- for ( i = 0 ; i < expandedTraces . length ; i ++ ) {
682- trace = expandedTraces [ i ] ;
683- colorAttrs = [ ] ;
684- path = [ ] ;
680+ path = [ ] ;
685681
686- if ( ! trace || ! trace . _module ) continue ;
682+ // Get the cached colorAttrs:
683+ colorAttrs = trace . _module . _colorAttrs ;
687684
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+ }
689693
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 ) ;
692699 }
693700 }
694701} ;
@@ -728,11 +735,9 @@ plots.supplyDataDefaults = function(dataIn, dataOut, layout, fullLayout) {
728735 if ( fullTrace . transforms && fullTrace . transforms . length ) {
729736 var expandedTraces = applyTransforms ( fullTrace , dataOut , layout , fullLayout ) ;
730737
731- plots . clearExpandedTraceDefaultColors ( expandedTraces ) ;
732-
733738 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 ) ;
736741
737742 // mutate uid here using parent uid and expanded index
738743 // to promote consistency between update calls
0 commit comments