@@ -205,7 +205,7 @@ Plotly.plot = function(gd, data, layout, config) {
205
205
if ( ! recalc ) return ;
206
206
207
207
var subplots = Plots . getSubplotIds ( fullLayout , 'cartesian' ) ,
208
- modules = gd . _modules ;
208
+ modules = fullLayout . _modules ;
209
209
210
210
// position and range calculations for traces that
211
211
// depend on each other ie bars (stacked or grouped)
@@ -250,11 +250,12 @@ Plotly.plot = function(gd, data, layout, config) {
250
250
251
251
// Now plot the data
252
252
function drawData ( ) {
253
- var calcdata = gd . calcdata ;
253
+ var calcdata = gd . calcdata ,
254
+ i ;
254
255
255
256
// in case of traces that were heatmaps or contour maps
256
257
// previously, remove them and their colorbars explicitly
257
- for ( var i = 0 ; i < calcdata . length ; i ++ ) {
258
+ for ( i = 0 ; i < calcdata . length ; i ++ ) {
258
259
var trace = calcdata [ i ] [ 0 ] . trace ,
259
260
isVisible = ( trace . visible === true ) ,
260
261
uid = trace . uid ;
@@ -272,18 +273,11 @@ Plotly.plot = function(gd, data, layout, config) {
272
273
}
273
274
}
274
275
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 ) ;
282
280
}
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?
287
281
288
282
// styling separate from drawing
289
283
Plots . style ( gd ) ;
@@ -1661,10 +1655,12 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
1661
1655
axlist ,
1662
1656
flagAxForDelete = { } ;
1663
1657
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
+ } ) ;
1668
1664
1669
1665
// make a new empty vals array for undoit
1670
1666
function a0 ( ) { return traces . map ( function ( ) { return undefined ; } ) ; }
@@ -2309,7 +2305,7 @@ Plotly.relayout = function relayout(gd, astr, val) {
2309
2305
if ( p . parts [ 0 ] . indexOf ( 'scene' ) === 0 ) doplot = true ;
2310
2306
else if ( p . parts [ 0 ] . indexOf ( 'geo' ) === 0 ) doplot = true ;
2311
2307
else if ( p . parts [ 0 ] . indexOf ( 'ternary' ) === 0 ) doplot = true ;
2312
- else if ( fullLayout . _hasGL2D &&
2308
+ else if ( fullLayout . _has ( 'gl2d' ) &&
2313
2309
( ai . indexOf ( 'axis' ) !== - 1 || p . parts [ 0 ] === 'plot_bgcolor' )
2314
2310
) doplot = true ;
2315
2311
else if ( ai === 'hiddenlabels' ) docalc = true ;
@@ -2582,9 +2578,6 @@ function makePlotFramework(gd) {
2582
2578
var gd3 = d3 . select ( gd ) ,
2583
2579
fullLayout = gd . _fullLayout ;
2584
2580
2585
- // TODO - find a better place for 3D to initialize axes
2586
- if ( fullLayout . _hasGL3D ) Plots . subplotsRegistry . gl3d . initAxes ( gd ) ;
2587
-
2588
2581
// Plot container
2589
2582
fullLayout . _container = gd3 . selectAll ( '.plot-container' ) . data ( [ 0 ] ) ;
2590
2583
fullLayout . _container . enter ( ) . insert ( 'div' , ':first-child' )
@@ -2659,7 +2652,7 @@ function makePlotFramework(gd) {
2659
2652
makeSubplots ( gd , subplots ) ;
2660
2653
}
2661
2654
2662
- if ( fullLayout . _hasCartesian ) makeCartesianPlotFramwork ( gd , subplots ) ;
2655
+ if ( fullLayout . _has ( 'cartesian' ) ) makeCartesianPlotFramwork ( gd , subplots ) ;
2663
2656
2664
2657
// single ternary layer for the whole plot
2665
2658
fullLayout . _ternarylayer = fullLayout . _paper . append ( 'g' ) . classed ( 'ternarylayer' , true ) ;
0 commit comments