@@ -16,7 +16,9 @@ var Plotly = require('../plotly');
1616var Registry = require ( '../registry' ) ;
1717var Lib = require ( '../lib' ) ;
1818var Color = require ( '../components/color' ) ;
19+
1920var plots = module . exports = { } ;
21+
2022var animationAttrs = require ( './animation_attributes' ) ;
2123var frameAttrs = require ( './frame_attributes' ) ;
2224
@@ -786,52 +788,15 @@ function applyTransforms(fullTrace, fullData, layout) {
786788 var container = fullTrace . transforms ,
787789 dataOut = [ fullTrace ] ;
788790
789- var attributeSets = dataOut . map ( function ( trace ) {
790-
791- var arraySplitAttributes = [ ] ;
792-
793- var stack = [ ] ;
794-
795- /**
796- * A closure that gathers attribute paths into its enclosed arraySplitAttributes
797- * Attribute paths are collected iff their leaf node is a splittable attribute
798- * @callback callback
799- * @param {object } attr an attribute
800- * @param {String } attrName name string
801- * @param {object[] } attrs all the attributes
802- * @param {Number } level the recursion level, 0 at the root
803- * @closureVariable {String[][]} arraySplitAttributes the set of gathered attributes
804- * Example of filled closure variable (expected to be initialized to []):
805- * [["marker","size"],["marker","line","width"],["marker","line","color"]]
806- */
807- function callback ( attr , attrName , attrs , level ) {
808-
809- stack = stack . slice ( 0 , level ) . concat ( [ attrName ] ) ;
810-
811- var splittableAttr = attr . valType === 'data_array' || attr . arrayOk === true ;
812- if ( splittableAttr ) {
813- arraySplitAttributes . push ( stack . slice ( ) ) ;
814- }
815- }
816-
817- Lib . crawl ( trace . _module . attributes , callback ) ;
818-
819- return arraySplitAttributes . map ( function ( path ) {
820- return path . join ( '.' ) ;
821- } ) ;
822- } ) ;
823-
824791 for ( var i = 0 ; i < container . length ; i ++ ) {
825792 var transform = container [ i ] ,
826- type = transform . type ,
827- _module = transformsRegistry [ type ] ;
793+ _module = transformsRegistry [ transform . type ] ;
828794
829- if ( _module ) {
795+ if ( _module && _module . transform ) {
830796 dataOut = _module . transform ( dataOut , {
831797 transform : transform ,
832798 fullTrace : fullTrace ,
833799 fullData : fullData ,
834- attributeSets : attributeSets ,
835800 layout : layout ,
836801 transformIndex : i
837802 } ) ;
@@ -1617,7 +1582,7 @@ plots.doCalcdata = function(gd, traces) {
16171582 var axList = Plotly . Axes . list ( gd ) ,
16181583 fullData = gd . _fullData ,
16191584 fullLayout = gd . _fullLayout ,
1620- i ;
1585+ i , j ;
16211586
16221587 // XXX: Is this correct? Needs a closer look so that *some* traces can be recomputed without
16231588 // *all* needing doCalcdata:
@@ -1655,7 +1620,6 @@ plots.doCalcdata = function(gd, traces) {
16551620 }
16561621
16571622 var trace = fullData [ i ] ,
1658- _module = trace . _module ,
16591623 cd = [ ] ;
16601624
16611625 // If traces were specified and this trace was not included, then transfer it over from
@@ -1665,8 +1629,30 @@ plots.doCalcdata = function(gd, traces) {
16651629 continue ;
16661630 }
16671631
1668- if ( _module && trace . visible === true ) {
1669- if ( _module . calc ) cd = _module . calc ( gd , trace ) ;
1632+ var _module ;
1633+ if ( trace . visible === true ) {
1634+
1635+ // call calcTransform method if any
1636+ if ( trace . transforms ) {
1637+
1638+ // we need one round of trace module calc before
1639+ // the calc transform to 'fill in' the categories list
1640+ // used for example in the data-to-coordinate method
1641+ _module = trace . _module ;
1642+ if ( _module && _module . calc ) _module . calc ( gd , trace ) ;
1643+
1644+ for ( j = 0 ; j < trace . transforms . length ; j ++ ) {
1645+ var transform = trace . transforms [ j ] ;
1646+
1647+ _module = transformsRegistry [ transform . type ] ;
1648+ if ( _module && _module . calcTransform ) {
1649+ _module . calcTransform ( gd , trace , transform ) ;
1650+ }
1651+ }
1652+ }
1653+
1654+ _module = trace . _module ;
1655+ if ( _module && _module . calc ) cd = _module . calc ( gd , trace ) ;
16701656 }
16711657
16721658 // make sure there is a first point
0 commit comments