@@ -205,7 +205,7 @@ Plotly.plot = function(gd, data, layout, config) {
205205 if ( ! recalc ) return ;
206206
207207 var subplots = Plots . getSubplotIds ( fullLayout , 'cartesian' ) ,
208- modules = gd . _modules ;
208+ modules = fullLayout . _modules ;
209209
210210 // position and range calculations for traces that
211211 // depend on each other ie bars (stacked or grouped)
@@ -250,11 +250,12 @@ Plotly.plot = function(gd, data, layout, config) {
250250
251251 // Now plot the data
252252 function drawData ( ) {
253- var calcdata = gd . calcdata ;
253+ var calcdata = gd . calcdata ,
254+ i ;
254255
255256 // in case of traces that were heatmaps or contour maps
256257 // previously, remove them and their colorbars explicitly
257- for ( var i = 0 ; i < calcdata . length ; i ++ ) {
258+ for ( i = 0 ; i < calcdata . length ; i ++ ) {
258259 var trace = calcdata [ i ] [ 0 ] . trace ,
259260 isVisible = ( trace . visible === true ) ,
260261 uid = trace . uid ;
@@ -272,18 +273,11 @@ Plotly.plot = function(gd, data, layout, config) {
272273 }
273274 }
274275
275- var plotRegistry = Plots . subplotsRegistry ;
276-
277- if ( fullLayout . _hasGL3D ) plotRegistry . gl3d . plot ( gd ) ;
278- if ( fullLayout . _hasGeo ) plotRegistry . geo . plot ( gd ) ;
279- if ( fullLayout . _hasGL2D ) plotRegistry . gl2d . plot ( gd ) ;
280- if ( fullLayout . _hasCartesian || fullLayout . _hasPie ) {
281- plotRegistry . cartesian . plot ( gd ) ;
276+ // loop over the base plot modules present on graph
277+ var basePlotModules = fullLayout . _basePlotModules ;
278+ for ( i = 0 ; i < basePlotModules . length ; i ++ ) {
279+ basePlotModules [ i ] . plot ( gd ) ;
282280 }
283- if ( fullLayout . _hasTernary ) plotRegistry . ternary . plot ( gd ) ;
284-
285- // clean up old scenes that no longer have associated data
286- // will this be a performance hit?
287281
288282 // styling separate from drawing
289283 Plots . style ( gd ) ;
@@ -1661,10 +1655,12 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
16611655 axlist ,
16621656 flagAxForDelete = { } ;
16631657
1664- // for now, if we detect gl or geo stuff, just re-do the plot
1665- if ( fullLayout . _hasGL3D || fullLayout . _hasGeo || fullLayout . _hasGL2D ) {
1666- doplot = true ;
1667- }
1658+ // At the moment, only cartesian, pie and ternary plot types can afford
1659+ // to not go through a full replot
1660+ var doPlotWhiteList = [ 'cartesian' , 'pie' , 'ternary' ] ;
1661+ fullLayout . _basePlotModules . forEach ( function ( _module ) {
1662+ if ( doPlotWhiteList . indexOf ( _module . name ) === - 1 ) doplot = true ;
1663+ } ) ;
16681664
16691665 // make a new empty vals array for undoit
16701666 function a0 ( ) { return traces . map ( function ( ) { return undefined ; } ) ; }
@@ -2309,7 +2305,7 @@ Plotly.relayout = function relayout(gd, astr, val) {
23092305 if ( p . parts [ 0 ] . indexOf ( 'scene' ) === 0 ) doplot = true ;
23102306 else if ( p . parts [ 0 ] . indexOf ( 'geo' ) === 0 ) doplot = true ;
23112307 else if ( p . parts [ 0 ] . indexOf ( 'ternary' ) === 0 ) doplot = true ;
2312- else if ( fullLayout . _hasGL2D &&
2308+ else if ( fullLayout . _has ( 'gl2d' ) &&
23132309 ( ai . indexOf ( 'axis' ) !== - 1 || p . parts [ 0 ] === 'plot_bgcolor' )
23142310 ) doplot = true ;
23152311 else if ( ai === 'hiddenlabels' ) docalc = true ;
@@ -2582,9 +2578,6 @@ function makePlotFramework(gd) {
25822578 var gd3 = d3 . select ( gd ) ,
25832579 fullLayout = gd . _fullLayout ;
25842580
2585- // TODO - find a better place for 3D to initialize axes
2586- if ( fullLayout . _hasGL3D ) Plots . subplotsRegistry . gl3d . initAxes ( gd ) ;
2587-
25882581 // Plot container
25892582 fullLayout . _container = gd3 . selectAll ( '.plot-container' ) . data ( [ 0 ] ) ;
25902583 fullLayout . _container . enter ( ) . insert ( 'div' , ':first-child' )
@@ -2659,7 +2652,7 @@ function makePlotFramework(gd) {
26592652 makeSubplots ( gd , subplots ) ;
26602653 }
26612654
2662- if ( fullLayout . _hasCartesian ) makeCartesianPlotFramwork ( gd , subplots ) ;
2655+ if ( fullLayout . _has ( 'cartesian' ) ) makeCartesianPlotFramwork ( gd , subplots ) ;
26632656
26642657 // single ternary layer for the whole plot
26652658 fullLayout . _ternarylayer = fullLayout . _paper . append ( 'g' ) . classed ( 'ternarylayer' , true ) ;
0 commit comments