@@ -282,7 +282,6 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
282
282
. attr ( 'class' , function ( d ) { return d . className ; } )
283
283
. classed ( 'mlayer' , true )
284
284
. classed ( 'rangeplot' , plotinfo . isRangePlot ) ;
285
-
286
285
layers . exit ( ) . remove ( ) ;
287
286
288
287
layers . order ( ) ;
@@ -402,12 +401,11 @@ exports.drawFramework = function(gd) {
402
401
subplotLayers . enter ( ) . append ( 'g' )
403
402
. attr ( 'class' , function ( d ) { return 'subplot ' + d [ 0 ] ; } ) ;
404
403
405
- //subplotLayers.order();
404
+ subplotLayers . order ( ) ;
405
+
406
+ subplotLayers . exit ( )
407
+ . call ( purgeSubplotLayers , fullLayout ) ;
406
408
407
- //subplotLayers.exit()
408
- // .call(purgeSubplotLayers, fullLayout);
409
- console . log ( "Subplotlayers" )
410
- console . log ( subplotLayers )
411
409
subplotLayers . each ( function ( d ) {
412
410
var id = d [ 0 ] ;
413
411
var plotinfo = fullLayout . _plots [ id ] ;
@@ -431,7 +429,7 @@ exports.rangePlot = function(gd, plotinfo, cdSubplot) {
431
429
function makeSubplotData ( gd ) {
432
430
var fullLayout = gd . _fullLayout ;
433
431
var ids = fullLayout . _subplots . cartesian ;
434
- var len = ids . length ;
432
+
435
433
var i , j , id , plotinfo , xa , ya ;
436
434
437
435
// split 'regular' and 'overlaying' subplots
@@ -454,29 +452,24 @@ function makeSubplotData(gd) {
454
452
var zindices = Object . keys ( subplotZindexGroups )
455
453
. map ( Number )
456
454
. sort ( Lib . sorterAsc ) ;
457
-
458
- console . log ( subplotZindexGroups )
455
+ var len = zindices . length ;
459
456
460
- for ( i = 0 ; i < zindices . length ; i ++ ) {
461
- console . log ( i )
457
+ for ( i = 0 ; i < len ; i ++ ) {
462
458
var zindex = subplotZindexGroups [ zindices [ i ] ] ;
463
- console . log ( zindex )
464
- console . log ( )
465
459
var ids = Object . keys ( zindex ) ;
466
460
for ( var j = 0 ; j < ids . length ; j ++ ) {
467
461
var id = ids [ j ] ;
468
462
plotinfo = fullLayout . _plots [ id ] ;
469
- //xa = plotinfo.xaxis;
470
- //ya = plotinfo.yaxis;
471
463
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 ] )
476
466
plotinfo . overlays = [ ] ;
477
467
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 ) {
480
473
plotinfo . mainplot = mainplot ;
481
474
plotinfo . mainplotinfo = mainplotinfo ;
482
475
overlays . push ( id ) ;
@@ -485,44 +478,40 @@ function makeSubplotData(gd) {
485
478
plotinfo . mainplotinfo = undefined ;
486
479
regulars . push ( id ) ;
487
480
}
488
- console . log ( "....." )
489
481
}
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 ;
497
482
}
498
483
499
- regulars = regulars . filter ( onlyUnique ) ;
500
- overlays = overlays . filter ( onlyUnique ) ;
501
- console . log ( regulars , overlays )
502
484
// fill in list of overlaying subplots in 'main plot'
503
485
for ( i = 0 ; i < overlays . length ; i ++ ) {
504
486
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 ) ;
507
493
}
508
494
509
495
// put 'regular' subplot data before 'overlaying'
510
496
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 ++ ) {
514
499
id = subplotIds [ i ] ;
500
+ if ( id . indexOf ( '-over-' ) !== - 1 ) {
501
+ fullLayout . _plots [ id ] = Object . assign ( { } , fullLayout . _plots [ id . split ( "-over-" ) [ 0 ] ] ) ;
502
+ }
515
503
plotinfo = fullLayout . _plots [ id ] ;
516
- console . log ( id , plotinfo )
517
504
xa = plotinfo . xaxis ;
518
505
ya = plotinfo . yaxis ;
519
506
520
507
// use info about axis layer and overlaying pattern
521
508
// 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
+ }
526
515
subplotData [ i ] = d ;
527
516
}
528
517
return subplotData ;
@@ -535,7 +524,7 @@ function makeSubplotLayer(gd, plotinfo) {
535
524
var yLayer = constants . layerValue2layerClass [ plotinfo . yaxis . layer ] ;
536
525
var hasOnlyLargeSploms = gd . _fullLayout . _hasOnlyLargeSploms ;
537
526
538
- if ( ! plotinfo . mainplot ) {
527
+ if ( ! plotinfo . mainplot || id . indexOf ( '-over-' ) === - 1 ) {
539
528
if ( hasOnlyLargeSploms ) {
540
529
// TODO could do even better
541
530
// - we don't need plot (but we would have to mock it in lsInner
@@ -598,22 +587,21 @@ function makeSubplotLayer(gd, plotinfo) {
598
587
plotinfo . minorGridlayer = mainplotinfo . minorGridlayer ;
599
588
plotinfo . gridlayer = mainplotinfo . gridlayer ;
600
589
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 )
606
590
591
+ ensureSingle ( mainplotinfo . overlinesBelow , 'path' , xId ) ;
607
592
ensureSingle ( mainplotinfo . overlinesBelow , 'path' , yId ) ;
593
+
608
594
ensureSingle ( mainplotinfo . overaxesBelow , 'g' , xId ) ;
609
595
ensureSingle ( mainplotinfo . overaxesBelow , 'g' , yId ) ;
610
596
611
597
plotinfo . plot = ensureSingle ( mainplotinfo . overplot , 'g' , id ) ;
612
598
613
599
ensureSingle ( mainplotinfo . overlinesAbove , 'path' , xId ) ;
614
600
ensureSingle ( mainplotinfo . overlinesAbove , 'path' , yId ) ;
601
+
615
602
ensureSingle ( mainplotinfo . overaxesAbove , 'g' , xId ) ;
616
603
ensureSingle ( mainplotinfo . overaxesAbove , 'g' , yId ) ;
604
+
617
605
618
606
// set refs to correct layers as determined by 'abovetraces'
619
607
plotinfo . xlines = mainplotgroup . select ( '.overlines-' + xLayer ) . select ( '.' + xId ) ;
@@ -625,17 +613,21 @@ function makeSubplotLayer(gd, plotinfo) {
625
613
// common attributes for all subplots, overlays or not
626
614
627
615
if ( ! hasOnlyLargeSploms ) {
628
- ensureSingleAndAddDatum ( plotinfo . minorGridlayer , 'g' , plotinfo . xaxis . _id ) ;
616
+ if ( plotinfo . minorGridlayer ) {
617
+ ensureSingleAndAddDatum ( plotinfo . minorGridlayer , 'g' , plotinfo . xaxis . _id ) ;
629
618
ensureSingleAndAddDatum ( plotinfo . minorGridlayer , 'g' , plotinfo . yaxis . _id ) ;
630
619
plotinfo . minorGridlayer . selectAll ( 'g' )
631
620
. map ( function ( d ) { return d [ 0 ] ; } )
632
621
. sort ( axisIds . idSort ) ;
633
622
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
+ }
639
631
}
640
632
641
633
plotinfo . xlines
0 commit comments