@@ -21,8 +21,6 @@ var Queue = require('../lib/queue');
2121var Plots = require ( '../plots/plots' ) ;
2222var Fx = require ( '../plots/cartesian/graph_interact' ) ;
2323
24- var Pie = require ( '../traces/pie' ) ;
25-
2624var Color = require ( '../components/color' ) ;
2725var Drawing = require ( '../components/drawing' ) ;
2826var ErrorBars = require ( '../components/errorbars' ) ;
@@ -268,12 +266,16 @@ Plotly.plot = function(gd, data, layout, config) {
268266
269267 function getCdModule ( cdSubplot , _module ) {
270268 var cdModule = [ ] ;
271- var i , cd , trace ;
272- for ( i = 0 ; i < cdSubplot . length ; i ++ ) {
273- cd = cdSubplot [ i ] ;
274- trace = cd [ 0 ] . trace ;
275- if ( trace . _module === _module && trace . visible === true ) cdModule . push ( cd ) ;
269+
270+ for ( var i = 0 ; i < cdSubplot . length ; i ++ ) {
271+ var cd = cdSubplot [ i ] ;
272+ var trace = cd [ 0 ] . trace ;
273+
274+ if ( ( trace . _module === _module ) && ( trace . visible === true ) ) {
275+ cdModule . push ( cd ) ;
276+ }
276277 }
278+
277279 return cdModule ;
278280 }
279281
@@ -301,7 +303,7 @@ Plotly.plot = function(gd, data, layout, config) {
301303
302304 for ( i = 0 ; i < subplots . length ; i ++ ) {
303305 subplot = subplots [ i ] ;
304- subplotInfo = gd . _fullLayout . _plots [ subplot ] ;
306+ subplotInfo = fullLayout . _plots [ subplot ] ;
305307 cdSubplot = getCdSubplot ( calcdata , subplot ) ;
306308 cdError = [ ] ;
307309
@@ -312,7 +314,8 @@ Plotly.plot = function(gd, data, layout, config) {
312314
313315 for ( j = 0 ; j < modules . length ; j ++ ) {
314316 _module = modules [ j ] ;
315- if ( ! _module . plot ) continue ;
317+
318+ if ( ! _module . plot && ( _module . name === 'pie' ) ) continue ;
316319
317320 // plot all traces of this type on this subplot at once
318321 cdModule = getCdModule ( cdSubplot , _module ) ;
@@ -326,16 +329,19 @@ Plotly.plot = function(gd, data, layout, config) {
326329 }
327330
328331 // finally do all error bars at once
329- if ( gd . _fullLayout . _hasCartesian ) {
332+ if ( fullLayout . _hasCartesian ) {
330333 ErrorBars . plot ( gd , subplotInfo , cdError ) ;
331334 Lib . markTime ( 'done ErrorBars' ) ;
332335 }
333336 }
334337
335- // now draw stuff not on subplots (ie, pies)
336- // TODO: gotta be a better way to handle this
337- var cdPie = getCdModule ( calcdata , Pie ) ;
338- if ( cdPie . length ) Pie . plot ( gd , cdPie ) ;
338+ // now draw stuff not on subplots (ie, only pies at the moment)
339+ if ( fullLayout . _hasPie ) {
340+ var Pie = Plots . getModule ( 'pie' ) ;
341+ var cdPie = getCdModule ( calcdata , Pie ) ;
342+
343+ if ( cdPie . length ) Pie . plot ( gd , cdPie ) ;
344+ }
339345
340346 // styling separate from drawing
341347 Plots . style ( gd ) ;
0 commit comments