@@ -229,6 +229,15 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
229229 var hadGl , hasGl ;
230230 var i , k , subplotInfo , moduleName ;
231231
232+ // when going from a large splom graph to something else,
233+ // we need to clear <g subplot> so that the new cartesian subplot
234+ // can have the correct layer ordering
235+ if ( oldFullLayout . _hasOnlyLargeSploms && ! newFullLayout . _hasOnlyLargeSploms ) {
236+ for ( k in oldPlots ) {
237+ subplotInfo = oldPlots [ k ] ;
238+ if ( subplotInfo . plotgroup ) subplotInfo . plotgroup . remove ( ) ;
239+ }
240+ }
232241
233242 for ( i = 0 ; i < oldModules . length ; i ++ ) {
234243 moduleName = oldModules [ i ] . name ;
@@ -330,7 +339,7 @@ exports.drawFramework = function(gd) {
330339 // initialize list of overlay subplots
331340 plotinfo . overlays = [ ] ;
332341
333- makeSubplotLayer ( plotinfo ) ;
342+ makeSubplotLayer ( gd , plotinfo ) ;
334343
335344 // fill in list of overlay subplots
336345 if ( plotinfo . mainplot ) {
@@ -346,7 +355,7 @@ exports.drawFramework = function(gd) {
346355} ;
347356
348357exports . rangePlot = function ( gd , plotinfo , cdSubplot ) {
349- makeSubplotLayer ( plotinfo ) ;
358+ makeSubplotLayer ( gd , plotinfo ) ;
350359 plotOne ( gd , plotinfo , cdSubplot ) ;
351360 Plots . style ( gd ) ;
352361} ;
@@ -377,45 +386,58 @@ function makeSubplotData(gd) {
377386 return subplotData ;
378387}
379388
380- function makeSubplotLayer ( plotinfo ) {
389+ function makeSubplotLayer ( gd , plotinfo ) {
381390 var plotgroup = plotinfo . plotgroup ;
382391 var id = plotinfo . id ;
383392 var xLayer = constants . layerValue2layerClass [ plotinfo . xaxis . layer ] ;
384393 var yLayer = constants . layerValue2layerClass [ plotinfo . yaxis . layer ] ;
394+ var hasOnlyLargeSploms = gd . _fullLayout . _hasOnlyLargeSploms ;
385395
386396 if ( ! plotinfo . mainplot ) {
387- var backLayer = ensureSingle ( plotgroup , 'g' , 'layer-subplot' ) ;
388- plotinfo . shapelayer = ensureSingle ( backLayer , 'g' , 'shapelayer' ) ;
389- plotinfo . imagelayer = ensureSingle ( backLayer , 'g' , 'imagelayer' ) ;
390-
391- plotinfo . gridlayer = ensureSingle ( plotgroup , 'g' , 'gridlayer' ) ;
397+ if ( hasOnlyLargeSploms ) {
398+ // TODO could do even better
399+ // - we don't need plot (but we would have to mock it in lsInner
400+ // and other places
401+ // - we don't (x|y)lines and (x|y)axislayer for most subplots
402+ // usually just the bottom x and left y axes.
403+ plotinfo . plot = ensureSingle ( plotgroup , 'g' , 'plot' ) ;
404+ plotinfo . xlines = ensureSingle ( plotgroup , 'path' , 'xlines-above' ) ;
405+ plotinfo . ylines = ensureSingle ( plotgroup , 'path' , 'ylines-above' ) ;
406+ plotinfo . xaxislayer = ensureSingle ( plotgroup , 'g' , 'xaxislayer-above' ) ;
407+ plotinfo . yaxislayer = ensureSingle ( plotgroup , 'g' , 'yaxislayer-above' ) ;
408+ }
409+ else {
410+ var backLayer = ensureSingle ( plotgroup , 'g' , 'layer-subplot' ) ;
411+ plotinfo . shapelayer = ensureSingle ( backLayer , 'g' , 'shapelayer' ) ;
412+ plotinfo . imagelayer = ensureSingle ( backLayer , 'g' , 'imagelayer' ) ;
392413
393- plotinfo . zerolinelayer = ensureSingle ( plotgroup , 'g' , 'zerolinelayer' ) ;
414+ plotinfo . gridlayer = ensureSingle ( plotgroup , 'g' , 'gridlayer' ) ;
415+ plotinfo . zerolinelayer = ensureSingle ( plotgroup , 'g' , 'zerolinelayer' ) ;
394416
395- ensureSingle ( plotgroup , 'path' , 'xlines-below' ) ;
396- ensureSingle ( plotgroup , 'path' , 'ylines-below' ) ;
397- plotinfo . overlinesBelow = ensureSingle ( plotgroup , 'g' , 'overlines-below' ) ;
417+ ensureSingle ( plotgroup , 'path' , 'xlines-below' ) ;
418+ ensureSingle ( plotgroup , 'path' , 'ylines-below' ) ;
419+ plotinfo . overlinesBelow = ensureSingle ( plotgroup , 'g' , 'overlines-below' ) ;
398420
399- ensureSingle ( plotgroup , 'g' , 'xaxislayer-below' ) ;
400- ensureSingle ( plotgroup , 'g' , 'yaxislayer-below' ) ;
401- plotinfo . overaxesBelow = ensureSingle ( plotgroup , 'g' , 'overaxes-below' ) ;
421+ ensureSingle ( plotgroup , 'g' , 'xaxislayer-below' ) ;
422+ ensureSingle ( plotgroup , 'g' , 'yaxislayer-below' ) ;
423+ plotinfo . overaxesBelow = ensureSingle ( plotgroup , 'g' , 'overaxes-below' ) ;
402424
403- plotinfo . plot = ensureSingle ( plotgroup , 'g' , 'plot' ) ;
404- plotinfo . overplot = ensureSingle ( plotgroup , 'g' , 'overplot' ) ;
425+ plotinfo . plot = ensureSingle ( plotgroup , 'g' , 'plot' ) ;
426+ plotinfo . overplot = ensureSingle ( plotgroup , 'g' , 'overplot' ) ;
405427
406- ensureSingle ( plotgroup , 'path' , 'xlines-above' ) ;
407- ensureSingle ( plotgroup , 'path' , 'ylines-above' ) ;
408- plotinfo . overlinesAbove = ensureSingle ( plotgroup , 'g' , 'overlines-above' ) ;
428+ plotinfo . xlines = ensureSingle ( plotgroup , 'path' , 'xlines-above' ) ;
429+ plotinfo . ylines = ensureSingle ( plotgroup , 'path' , 'ylines-above' ) ;
409430
410- ensureSingle ( plotgroup , 'g' , 'xaxislayer-above' ) ;
411- ensureSingle ( plotgroup , 'g' , 'yaxislayer-above' ) ;
412- plotinfo . overaxesAbove = ensureSingle ( plotgroup , 'g' , 'overaxes-above' ) ;
431+ ensureSingle ( plotgroup , 'g' , 'xaxislayer-above' ) ;
432+ ensureSingle ( plotgroup , 'g' , 'yaxislayer-above' ) ;
433+ plotinfo . overaxesAbove = ensureSingle ( plotgroup , 'g' , 'overaxes-above' ) ;
413434
414- // set refs to correct layers as determined by 'axis.layer'
415- plotinfo . xlines = plotgroup . select ( '.xlines-' + xLayer ) ;
416- plotinfo . ylines = plotgroup . select ( '.ylines-' + yLayer ) ;
417- plotinfo . xaxislayer = plotgroup . select ( '.xaxislayer-' + xLayer ) ;
418- plotinfo . yaxislayer = plotgroup . select ( '.yaxislayer-' + yLayer ) ;
435+ // set refs to correct layers as determined by 'axis.layer'
436+ plotinfo . xlines = plotgroup . select ( '.xlines-' + xLayer ) ;
437+ plotinfo . ylines = plotgroup . select ( '.ylines-' + yLayer ) ;
438+ plotinfo . xaxislayer = plotgroup . select ( '.xaxislayer-' + xLayer ) ;
439+ plotinfo . yaxislayer = plotgroup . select ( '.yaxislayer-' + yLayer ) ;
440+ }
419441 }
420442 else {
421443 var mainplotinfo = plotinfo . mainplotinfo ;
@@ -450,14 +472,16 @@ function makeSubplotLayer(plotinfo) {
450472 plotinfo . yaxislayer = mainplotgroup . select ( '.overaxes-' + yLayer ) . select ( '.' + yId ) ;
451473 }
452474
453- ensureSingleAndAddDatum ( plotinfo . gridlayer , 'g' , plotinfo . xaxis . _id ) ;
454- ensureSingleAndAddDatum ( plotinfo . gridlayer , 'g' , plotinfo . yaxis . _id ) ;
455- plotinfo . gridlayer . selectAll ( 'g' ) . sort ( axisIds . idSort ) ;
456-
457475 // common attributes for all subplots, overlays or not
458476
459- for ( var i = 0 ; i < constants . traceLayerClasses . length ; i ++ ) {
460- ensureSingle ( plotinfo . plot , 'g' , constants . traceLayerClasses [ i ] ) ;
477+ if ( ! hasOnlyLargeSploms ) {
478+ ensureSingleAndAddDatum ( plotinfo . gridlayer , 'g' , plotinfo . xaxis . _id ) ;
479+ ensureSingleAndAddDatum ( plotinfo . gridlayer , 'g' , plotinfo . yaxis . _id ) ;
480+ plotinfo . gridlayer . selectAll ( 'g' ) . sort ( axisIds . idSort ) ;
481+
482+ for ( var i = 0 ; i < constants . traceLayerClasses . length ; i ++ ) {
483+ ensureSingle ( plotinfo . plot , 'g' , constants . traceLayerClasses [ i ] ) ;
484+ }
461485 }
462486
463487 plotinfo . xlines
0 commit comments