@@ -245,57 +245,15 @@ Plotly.plot = function(gd, data, layout, config) {
245
245
return Plotly . Axes . doTicks ( gd , 'redraw' ) ;
246
246
}
247
247
248
+ // Now plot the data
248
249
function drawData ( ) {
249
- // Now plot the data
250
- var calcdata = gd . calcdata ,
251
- subplots = Plots . getSubplotIds ( fullLayout , 'cartesian' ) ,
252
- modules = gd . _modules ;
253
-
254
- var i , j , trace , subplot , subplotInfo ,
255
- cdSubplot , cdError , cdModule , _module ;
256
-
257
- function getCdSubplot ( calcdata , subplot ) {
258
- var cdSubplot = [ ] ;
259
- var i , cd , trace ;
260
- for ( i = 0 ; i < calcdata . length ; i ++ ) {
261
- cd = calcdata [ i ] ;
262
- trace = cd [ 0 ] . trace ;
263
- if ( trace . xaxis + trace . yaxis === subplot ) cdSubplot . push ( cd ) ;
264
- }
265
- return cdSubplot ;
266
- }
267
-
268
- function getCdModule ( cdSubplot , _module ) {
269
- var cdModule = [ ] ;
270
-
271
- for ( var i = 0 ; i < cdSubplot . length ; i ++ ) {
272
- var cd = cdSubplot [ i ] ;
273
- var trace = cd [ 0 ] . trace ;
274
-
275
- if ( ( trace . _module === _module ) && ( trace . visible === true ) ) {
276
- cdModule . push ( cd ) ;
277
- }
278
- }
279
-
280
- return cdModule ;
281
- }
282
-
283
- // clean up old scenes that no longer have associated data
284
- // will this be a performance hit?
285
-
286
- var plotRegistry = Plots . subplotsRegistry ;
287
-
288
- // TODO incorporate cartesian and polar plots into this paradigm
289
- if ( fullLayout . _hasGL3D ) plotRegistry . gl3d . plot ( gd ) ;
290
- if ( fullLayout . _hasGeo ) plotRegistry . geo . plot ( gd ) ;
291
- if ( fullLayout . _hasGL2D ) plotRegistry . gl2d . plot ( gd ) ;
250
+ var calcdata = gd . calcdata ;
292
251
293
252
// in case of traces that were heatmaps or contour maps
294
253
// previously, remove them and their colorbars explicitly
295
- for ( i = 0 ; i < calcdata . length ; i ++ ) {
296
- trace = calcdata [ i ] [ 0 ] . trace ;
297
-
298
- var isVisible = ( trace . visible === true ) ,
254
+ for ( var i = 0 ; i < calcdata . length ; i ++ ) {
255
+ var trace = calcdata [ i ] [ 0 ] . trace ,
256
+ isVisible = ( trace . visible === true ) ,
299
257
uid = trace . uid ;
300
258
301
259
if ( ! isVisible || ! Plots . traceIs ( trace , '2dMap' ) ) {
@@ -311,47 +269,17 @@ Plotly.plot = function(gd, data, layout, config) {
311
269
}
312
270
}
313
271
314
- for ( i = 0 ; i < subplots . length ; i ++ ) {
315
- subplot = subplots [ i ] ;
316
- subplotInfo = fullLayout . _plots [ subplot ] ;
317
- cdSubplot = getCdSubplot ( calcdata , subplot ) ;
318
- cdError = [ ] ;
319
-
320
- // remove old traces, then redraw everything
321
- // TODO: use enter/exit appropriately in the plot functions
322
- // so we don't need this - should sometimes be a big speedup
323
- if ( subplotInfo . plot ) subplotInfo . plot . selectAll ( 'g.trace' ) . remove ( ) ;
324
-
325
- for ( j = 0 ; j < modules . length ; j ++ ) {
326
- _module = modules [ j ] ;
327
-
328
- if ( ! _module . plot && ( _module . name === 'pie' ) ) continue ;
329
-
330
- // plot all traces of this type on this subplot at once
331
- cdModule = getCdModule ( cdSubplot , _module ) ;
332
- _module . plot ( gd , subplotInfo , cdModule ) ;
333
- Lib . markTime ( 'done ' + ( cdModule [ 0 ] && cdModule [ 0 ] [ 0 ] . trace . type ) ) ;
334
-
335
- // collect the traces that may have error bars
336
- if ( cdModule [ 0 ] && cdModule [ 0 ] [ 0 ] . trace && Plots . traceIs ( cdModule [ 0 ] [ 0 ] . trace , 'errorBarsOK' ) ) {
337
- cdError = cdError . concat ( cdModule ) ;
338
- }
339
- }
272
+ var plotRegistry = Plots . subplotsRegistry ;
340
273
341
- // finally do all error bars at once
342
- if ( fullLayout . _hasCartesian ) {
343
- ErrorBars . plot ( gd , subplotInfo , cdError ) ;
344
- Lib . markTime ( 'done ErrorBars' ) ;
345
- }
274
+ if ( fullLayout . _hasGL3D ) plotRegistry . gl3d . plot ( gd ) ;
275
+ if ( fullLayout . _hasGeo ) plotRegistry . geo . plot ( gd ) ;
276
+ if ( fullLayout . _hasGL2D ) plotRegistry . gl2d . plot ( gd ) ;
277
+ if ( fullLayout . _hasCartesian || fullLayout . _hasPie ) {
278
+ plotRegistry . cartesian . plot ( gd ) ;
346
279
}
347
280
348
- // now draw stuff not on subplots (ie, only pies at the moment)
349
- if ( fullLayout . _hasPie ) {
350
- var Pie = Plots . getModule ( 'pie' ) ;
351
- var cdPie = getCdModule ( calcdata , Pie ) ;
352
-
353
- if ( cdPie . length ) Pie . plot ( gd , cdPie ) ;
354
- }
281
+ // clean up old scenes that no longer have associated data
282
+ // will this be a performance hit?
355
283
356
284
// styling separate from drawing
357
285
Plots . style ( gd ) ;
0 commit comments