@@ -282,7 +282,6 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
282282 . attr ( 'class' , function ( d ) { return d . className ; } )
283283 . classed ( 'mlayer' , true )
284284 . classed ( 'rangeplot' , plotinfo . isRangePlot ) ;
285-
286285 layers . exit ( ) . remove ( ) ;
287286
288287 layers . order ( ) ;
@@ -402,12 +401,11 @@ exports.drawFramework = function(gd) {
402401 subplotLayers . enter ( ) . append ( 'g' )
403402 . attr ( 'class' , function ( d ) { return 'subplot ' + d [ 0 ] ; } ) ;
404403
405- //subplotLayers.order();
404+ subplotLayers . order ( ) ;
405+
406+ subplotLayers . exit ( )
407+ . call ( purgeSubplotLayers , fullLayout ) ;
406408
407- //subplotLayers.exit()
408- // .call(purgeSubplotLayers, fullLayout);
409- console . log ( "Subplotlayers" )
410- console . log ( subplotLayers )
411409 subplotLayers . each ( function ( d ) {
412410 var id = d [ 0 ] ;
413411 var plotinfo = fullLayout . _plots [ id ] ;
@@ -431,7 +429,7 @@ exports.rangePlot = function(gd, plotinfo, cdSubplot) {
431429function makeSubplotData ( gd ) {
432430 var fullLayout = gd . _fullLayout ;
433431 var ids = fullLayout . _subplots . cartesian ;
434- var len = ids . length ;
432+
435433 var i , j , id , plotinfo , xa , ya ;
436434
437435 // split 'regular' and 'overlaying' subplots
@@ -454,29 +452,24 @@ function makeSubplotData(gd) {
454452 var zindices = Object . keys ( subplotZindexGroups )
455453 . map ( Number )
456454 . sort ( Lib . sorterAsc ) ;
457-
458- console . log ( subplotZindexGroups )
455+ var len = zindices . length ;
459456
460- for ( i = 0 ; i < zindices . length ; i ++ ) {
461- console . log ( i )
457+ for ( i = 0 ; i < len ; i ++ ) {
462458 var zindex = subplotZindexGroups [ zindices [ i ] ] ;
463- console . log ( zindex )
464- console . log ( )
465459 var ids = Object . keys ( zindex ) ;
466460 for ( var j = 0 ; j < ids . length ; j ++ ) {
467461 var id = ids [ j ] ;
468462 plotinfo = fullLayout . _plots [ id ] ;
469- //xa = plotinfo.xaxis;
470- //ya = plotinfo.yaxis;
471463
472- //var xa2 = xa._mainAxis;
473- //var ya2 = ya._mainAxis;
474- var mainplot = mainplot ? mainplot : id ; //xa2._id + ya2._id;
475- var mainplotinfo = fullLayout . _plots [ mainplot ] ;
464+ var mainplot = mainplot ? mainplot : id ;
465+ var mainplotinfo = Object . assign ( { } , fullLayout . _plots [ mainplot ] )
476466 plotinfo . overlays = [ ] ;
477467
478- if ( i !== 0 ) { //if(mainplot !== id && mainplotinfo) {
479- console . log ( "hererere" )
468+ if ( regulars . indexOf ( id ) !== - 1 || overlays . indexOf ( id ) !== - 1 ) {
469+ plotinfo . mainplot = mainplot ;
470+ plotinfo . mainplotinfo = mainplotinfo ;
471+ overlays . push ( id + '-over-' + i ) ;
472+ } else if ( mainplot !== id && mainplotinfo ) {
480473 plotinfo . mainplot = mainplot ;
481474 plotinfo . mainplotinfo = mainplotinfo ;
482475 overlays . push ( id ) ;
@@ -485,44 +478,40 @@ function makeSubplotData(gd) {
485478 plotinfo . mainplotinfo = undefined ;
486479 regulars . push ( id ) ;
487480 }
488- console . log ( "....." )
489481 }
490-
491- }
492- console . log ( plotinfo . mainplotinfo )
493- console . log ( "----" )
494- console . log ( regulars , overlays )
495- function onlyUnique ( value , index , array ) {
496- return array . indexOf ( value ) === index ;
497482 }
498483
499- regulars = regulars . filter ( onlyUnique ) ;
500- overlays = overlays . filter ( onlyUnique ) ;
501- console . log ( regulars , overlays )
502484 // fill in list of overlaying subplots in 'main plot'
503485 for ( i = 0 ; i < overlays . length ; i ++ ) {
504486 id = overlays [ i ] ;
505- plotinfo = fullLayout . _plots [ id ] ;
506- plotinfo . mainplotinfo . overlays . push ( plotinfo ) ;
487+ if ( id . indexOf ( '-over-' ) !== - 1 ) {
488+ id = id . split ( "-over-" ) [ 0 ] ;
489+ }
490+ var plotinfoCopy = Object . assign ( { } , fullLayout . _plots [ id ] ) ;
491+ plotinfoCopy . id = overlays [ i ] ;
492+ fullLayout . _plots [ id ] . mainplotinfo . overlays . push ( plotinfoCopy ) ;
507493 }
508494
509495 // put 'regular' subplot data before 'overlaying'
510496 var subplotIds = regulars . concat ( overlays ) ;
511- var subplotData = new Array ( len ) ;
512-
513- for ( i = 0 ; i < len ; i ++ ) {
497+ var subplotData = new Array ( subplotIds . length ) ;
498+ for ( i = 0 ; i < subplotIds . length ; i ++ ) {
514499 id = subplotIds [ i ] ;
500+ if ( id . indexOf ( '-over-' ) !== - 1 ) {
501+ fullLayout . _plots [ id ] = Object . assign ( { } , fullLayout . _plots [ id . split ( "-over-" ) [ 0 ] ] ) ;
502+ }
515503 plotinfo = fullLayout . _plots [ id ] ;
516- console . log ( id , plotinfo )
517504 xa = plotinfo . xaxis ;
518505 ya = plotinfo . yaxis ;
519506
520507 // use info about axis layer and overlaying pattern
521508 // to clean what need to be cleaned up in exit selection
522- var d = [ id , xa . layer , ya . layer , xa . overlaying || '' , ya . overlaying || '' ] ;
523- for ( j = 0 ; j < plotinfo . overlays . length ; j ++ ) {
524- d . push ( plotinfo . overlays [ j ] . id ) ;
525- }
509+ var d = [ id , xa . layer , ya . layer , xa . overlaying || '' , ya . overlaying || '' ] ;
510+ if ( id . indexOf ( '-over-' ) !== - 1 ) {
511+ for ( j = 0 ; j < plotinfo . overlays . length ; j ++ ) {
512+ d . push ( plotinfo . overlays [ j ] . id ) ;
513+ }
514+ }
526515 subplotData [ i ] = d ;
527516 }
528517 return subplotData ;
@@ -535,7 +524,7 @@ function makeSubplotLayer(gd, plotinfo) {
535524 var yLayer = constants . layerValue2layerClass [ plotinfo . yaxis . layer ] ;
536525 var hasOnlyLargeSploms = gd . _fullLayout . _hasOnlyLargeSploms ;
537526
538- if ( ! plotinfo . mainplot ) {
527+ if ( ! plotinfo . mainplot || id . indexOf ( '-over-' ) === - 1 ) {
539528 if ( hasOnlyLargeSploms ) {
540529 // TODO could do even better
541530 // - we don't need plot (but we would have to mock it in lsInner
@@ -598,22 +587,21 @@ function makeSubplotLayer(gd, plotinfo) {
598587 plotinfo . minorGridlayer = mainplotinfo . minorGridlayer ;
599588 plotinfo . gridlayer = mainplotinfo . gridlayer ;
600589 plotinfo . zerolinelayer = mainplotinfo . zerolinelayer ;
601- console . log ( xId )
602- console . log ( mainplotinfo )
603- console . log ( mainplotinfo . overlinesBelow )
604- ensureSingle ( mainplotinfo . overlinesBelow , 'path' , xId ) ;
605- console . log ( yId )
606590
591+ ensureSingle ( mainplotinfo . overlinesBelow , 'path' , xId ) ;
607592 ensureSingle ( mainplotinfo . overlinesBelow , 'path' , yId ) ;
593+
608594 ensureSingle ( mainplotinfo . overaxesBelow , 'g' , xId ) ;
609595 ensureSingle ( mainplotinfo . overaxesBelow , 'g' , yId ) ;
610596
611597 plotinfo . plot = ensureSingle ( mainplotinfo . overplot , 'g' , id ) ;
612598
613599 ensureSingle ( mainplotinfo . overlinesAbove , 'path' , xId ) ;
614600 ensureSingle ( mainplotinfo . overlinesAbove , 'path' , yId ) ;
601+
615602 ensureSingle ( mainplotinfo . overaxesAbove , 'g' , xId ) ;
616603 ensureSingle ( mainplotinfo . overaxesAbove , 'g' , yId ) ;
604+
617605
618606 // set refs to correct layers as determined by 'abovetraces'
619607 plotinfo . xlines = mainplotgroup . select ( '.overlines-' + xLayer ) . select ( '.' + xId ) ;
@@ -625,17 +613,21 @@ function makeSubplotLayer(gd, plotinfo) {
625613 // common attributes for all subplots, overlays or not
626614
627615 if ( ! hasOnlyLargeSploms ) {
628- ensureSingleAndAddDatum ( plotinfo . minorGridlayer , 'g' , plotinfo . xaxis . _id ) ;
616+ if ( plotinfo . minorGridlayer ) {
617+ ensureSingleAndAddDatum ( plotinfo . minorGridlayer , 'g' , plotinfo . xaxis . _id ) ;
629618 ensureSingleAndAddDatum ( plotinfo . minorGridlayer , 'g' , plotinfo . yaxis . _id ) ;
630619 plotinfo . minorGridlayer . selectAll ( 'g' )
631620 . map ( function ( d ) { return d [ 0 ] ; } )
632621 . sort ( axisIds . idSort ) ;
633622
634- ensureSingleAndAddDatum ( plotinfo . gridlayer , 'g' , plotinfo . xaxis . _id ) ;
635- ensureSingleAndAddDatum ( plotinfo . gridlayer , 'g' , plotinfo . yaxis . _id ) ;
636- plotinfo . gridlayer . selectAll ( 'g' )
637- . map ( function ( d ) { return d [ 0 ] ; } )
638- . sort ( axisIds . idSort ) ;
623+ }
624+ if ( plotinfo . gridlayer ) {
625+ ensureSingleAndAddDatum ( plotinfo . gridlayer , 'g' , plotinfo . xaxis . _id ) ;
626+ ensureSingleAndAddDatum ( plotinfo . gridlayer , 'g' , plotinfo . yaxis . _id ) ;
627+ plotinfo . gridlayer . selectAll ( 'g' )
628+ . map ( function ( d ) { return d [ 0 ] ; } )
629+ . sort ( axisIds . idSort ) ;
630+ }
639631 }
640632
641633 plotinfo . xlines
0 commit comments