@@ -2569,6 +2569,11 @@ describe('Cartesian taces with zindex', function() {
25692569 { x : [ 1 , 2 ] , y : [ 1 , 3 ] , type : 'scatter' , marker : { size : 20 } , zindex : 10 } ,
25702570 ] ;
25712571
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+
25722577 function fig ( data ) {
25732578 return {
25742579 data : data ,
@@ -2597,7 +2602,7 @@ describe('Cartesian taces with zindex', function() {
25972602 }
25982603 }
25992604
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 ) {
26012606 Plotly . newPlot ( gd , fig ( data0 ) )
26022607 . then ( function ( ) {
26032608 var data = gd . _fullData ;
@@ -2610,6 +2615,28 @@ describe('Cartesian taces with zindex', function() {
26102615 var data = gd . _fullData ;
26112616 assertZIndices ( data , data1 ) ;
26122617 } )
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+ } )
26132640 . then ( done , done . fail ) ;
26142641 } ) ;
26152642
@@ -2638,10 +2665,10 @@ describe('Cartesian taces with zindex', function() {
26382665 assertZIndicesSorted ( tracesData [ 0 ] ) ;
26392666 } )
26402667 . then ( function ( ) {
2641- return Plotly . restyle ( gd , 'type ' , 'bar' ) ;
2668+ return Plotly . restyle ( gd , 'marker.size ' , 20 ) ;
26422669 } )
26432670 . then ( function ( ) {
2644- var tracesData = d3SelectAll ( 'g[class^="barlayer "]' ) ;
2671+ var tracesData = d3SelectAll ( 'g[class^="scatterlayer "]' ) ;
26452672 var data = gd . _fullData ;
26462673 assertZIndices ( data , data0 ) ;
26472674 assertZIndicesSorted ( tracesData [ 0 ] ) ;
@@ -2656,45 +2683,38 @@ describe('Cartesian taces with zindex', function() {
26562683 assertZIndicesSorted ( tracesData [ 0 ] ) ;
26572684 } )
26582685 . then ( function ( ) {
2659- return Plotly . restyle ( gd , { type : 'bar' } ) ;
2686+ return Plotly . restyle ( gd , 'marker.size' , 20 ) ;
26602687 } )
26612688 . then ( function ( ) {
2662- var tracesData = d3SelectAll ( 'g[class^="barlayer "]' ) ;
2689+ var tracesData = d3SelectAll ( 'g[class^="scatterlayer "]' ) ;
26632690 var data = gd . _fullData ;
26642691 assertZIndices ( data , data1 ) ;
26652692 assertZIndicesSorted ( tracesData [ 0 ] ) ;
26662693 } )
26672694 . then ( done , done . fail ) ;
26682695 } ) ;
26692696
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 ) )
26762699 . 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 ] ) ;
26782704 } )
26792705 . then ( function ( ) {
2680- var tracesData = d3SelectAll ( 'g[class^="scatterlayer"]' ) [ 0 ] ;
2681- expect ( tracesData . length ) . toBe ( 1 ) ;
2706+ return Plotly . restyle ( gd , 'barmode' , 'overlay' ) ;
26822707 } )
2683- . then ( done , done . fail ) ;
2684- } ) ;
2685-
2686- it ( 'should be able to add traces' , function ( done ) {
2687- Plotly . newPlot ( gd , fig ( [ data0 [ 0 ] ] ) )
26882708 . 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 ] ) ;
26912711 } )
26922712 . then ( function ( ) {
2693- return Plotly . react ( gd , fig ( data0 ) ) ;
2713+ return Plotly . restyle ( gd , 'barmode' , 'stack' ) ;
26942714 } )
26952715 . 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 ] ) ;
26982718 } )
26992719 . then ( done , done . fail ) ;
27002720 } ) ;
0 commit comments