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