@@ -2569,6 +2569,11 @@ describe('Cartesian taces with zindex', function() {
2569
2569
{ x : [ 1 , 2 ] , y : [ 1 , 3 ] , type : 'scatter' , marker : { size : 20 } , zindex : 10 } ,
2570
2570
] ;
2571
2571
2572
+ var barData = [
2573
+ { x : [ 1 , 2 ] , y : [ 2 , 4 ] , type : 'bar' } ,
2574
+ { x : [ 1 , 2 ] , y : [ 4 , 2 ] , type : 'bar' , zindex : - 10 }
2575
+ ] ;
2576
+
2572
2577
function fig ( data ) {
2573
2578
return {
2574
2579
data : data ,
@@ -2597,7 +2602,7 @@ describe('Cartesian taces with zindex', function() {
2597
2602
}
2598
2603
}
2599
2604
2600
- it ( 'should be able to update zindex' , function ( done ) {
2605
+ it ( 'should be able to update and remove layers for scatter traces in respect to zindex' , function ( done ) {
2601
2606
Plotly . newPlot ( gd , fig ( data0 ) )
2602
2607
. then ( function ( ) {
2603
2608
var data = gd . _fullData ;
@@ -2610,6 +2615,28 @@ describe('Cartesian taces with zindex', function() {
2610
2615
var data = gd . _fullData ;
2611
2616
assertZIndices ( data , data1 ) ;
2612
2617
} )
2618
+ . then ( function ( ) {
2619
+ return Plotly . react ( gd , fig ( barData ) ) ;
2620
+ } )
2621
+ . then ( function ( ) {
2622
+ var data = gd . _fullData ;
2623
+ assertZIndices ( data , barData ) ;
2624
+ var scatterTraces = d3SelectAll ( 'g[class^="scatterlayer"]' ) [ 0 ] ;
2625
+ expect ( scatterTraces . length ) . toBe ( 0 ) ;
2626
+ var barTraces = d3SelectAll ( 'g[class^="barlayer"]' ) [ 0 ] ;
2627
+ expect ( barTraces . length ) . toBe ( 2 ) ;
2628
+ } )
2629
+ . then ( function ( ) {
2630
+ return Plotly . react ( gd , fig ( barData . concat ( data0 ) ) ) ;
2631
+ } )
2632
+ . then ( function ( ) {
2633
+ var data = gd . _fullData ;
2634
+ assertZIndices ( data , barData . concat ( data0 ) ) ;
2635
+ var scatterTraces = d3SelectAll ( 'g[class^="scatterlayer"]' ) [ 0 ] ;
2636
+ expect ( scatterTraces . length ) . toBe ( 3 ) ;
2637
+ var barTraces = d3SelectAll ( 'g[class^="barlayer"]' ) [ 0 ] ;
2638
+ expect ( barTraces . length ) . toBe ( 2 ) ;
2639
+ } )
2613
2640
. then ( done , done . fail ) ;
2614
2641
} ) ;
2615
2642
@@ -2638,10 +2665,10 @@ describe('Cartesian taces with zindex', function() {
2638
2665
assertZIndicesSorted ( tracesData [ 0 ] ) ;
2639
2666
} )
2640
2667
. then ( function ( ) {
2641
- return Plotly . restyle ( gd , 'type ' , 'bar' ) ;
2668
+ return Plotly . restyle ( gd , 'marker.size ' , 20 ) ;
2642
2669
} )
2643
2670
. then ( function ( ) {
2644
- var tracesData = d3SelectAll ( 'g[class^="barlayer "]' ) ;
2671
+ var tracesData = d3SelectAll ( 'g[class^="scatterlayer "]' ) ;
2645
2672
var data = gd . _fullData ;
2646
2673
assertZIndices ( data , data0 ) ;
2647
2674
assertZIndicesSorted ( tracesData [ 0 ] ) ;
@@ -2656,45 +2683,38 @@ describe('Cartesian taces with zindex', function() {
2656
2683
assertZIndicesSorted ( tracesData [ 0 ] ) ;
2657
2684
} )
2658
2685
. then ( function ( ) {
2659
- return Plotly . restyle ( gd , { type : 'bar' } ) ;
2686
+ return Plotly . restyle ( gd , 'marker.size' , 20 ) ;
2660
2687
} )
2661
2688
. then ( function ( ) {
2662
- var tracesData = d3SelectAll ( 'g[class^="barlayer "]' ) ;
2689
+ var tracesData = d3SelectAll ( 'g[class^="scatterlayer "]' ) ;
2663
2690
var data = gd . _fullData ;
2664
2691
assertZIndices ( data , data1 ) ;
2665
2692
assertZIndicesSorted ( tracesData [ 0 ] ) ;
2666
2693
} )
2667
2694
. then ( done , done . fail ) ;
2668
2695
} ) ;
2669
2696
2670
- it ( 'should be able to clear traces' , function ( done ) {
2671
- Plotly . newPlot ( gd , fig ( data0 ) )
2672
- . then ( function ( ) {
2673
- var tracesData = d3SelectAll ( 'g[class^="scatterlayer"]' ) [ 0 ] ;
2674
- expect ( tracesData . length ) . toBe ( 3 ) ;
2675
- } )
2697
+ it ( 'should display bar traces in ascending order' , function ( done ) {
2698
+ Plotly . newPlot ( gd , fig ( barData ) )
2676
2699
. then ( function ( ) {
2677
- return Plotly . react ( gd , fig ( [ data0 [ 0 ] ] ) ) ;
2700
+ var data = gd . _fullData ;
2701
+ assertZIndices ( data , barData ) ;
2702
+ var tracesData = d3SelectAll ( 'g[class^="barlayer"]' ) ;
2703
+ assertZIndicesSorted ( tracesData [ 0 ] ) ;
2678
2704
} )
2679
2705
. then ( function ( ) {
2680
- var tracesData = d3SelectAll ( 'g[class^="scatterlayer"]' ) [ 0 ] ;
2681
- expect ( tracesData . length ) . toBe ( 1 ) ;
2706
+ return Plotly . restyle ( gd , 'barmode' , 'overlay' ) ;
2682
2707
} )
2683
- . then ( done , done . fail ) ;
2684
- } ) ;
2685
-
2686
- it ( 'should be able to add traces' , function ( done ) {
2687
- Plotly . newPlot ( gd , fig ( [ data0 [ 0 ] ] ) )
2688
2708
. then ( function ( ) {
2689
- var tracesData = d3SelectAll ( 'g[class^="scatterlayer "]' ) [ 0 ] ;
2690
- expect ( tracesData . length ) . toBe ( 1 ) ;
2709
+ var tracesData = d3SelectAll ( 'g[class^="barlayer "]' ) ;
2710
+ assertZIndicesSorted ( tracesData [ 0 ] ) ;
2691
2711
} )
2692
2712
. then ( function ( ) {
2693
- return Plotly . react ( gd , fig ( data0 ) ) ;
2713
+ return Plotly . restyle ( gd , 'barmode' , 'stack' ) ;
2694
2714
} )
2695
2715
. then ( function ( ) {
2696
- var tracesData = d3SelectAll ( 'g[class^="scatterlayer "]' ) [ 0 ] ;
2697
- expect ( tracesData . length ) . toBe ( 3 ) ;
2716
+ var tracesData = d3SelectAll ( 'g[class^="barlayer "]' ) ;
2717
+ assertZIndicesSorted ( tracesData [ 0 ] ) ;
2698
2718
} )
2699
2719
. then ( done , done . fail ) ;
2700
2720
} ) ;
0 commit comments