@@ -15,15 +15,29 @@ describe('errorbar plotting', function() {
1515
1616 afterEach ( destroyGraphDiv ) ;
1717
18+ function countBars ( xCount , yCount ) {
19+ expect ( d3 . select ( gd ) . selectAll ( '.xerror' ) . size ( ) ) . toBe ( xCount ) ;
20+ expect ( d3 . select ( gd ) . selectAll ( '.yerror' ) . size ( ) ) . toBe ( yCount ) ;
21+ }
22+
23+ function checkCalcdata ( cdTrace , errorBarData ) {
24+ cdTrace . forEach ( function ( di , i ) {
25+ var ebi = errorBarData [ i ] || { } ;
26+ expect ( di . xh ) . toBe ( ebi . xh ) ;
27+ expect ( di . xs ) . toBe ( ebi . xs ) ;
28+ expect ( di . yh ) . toBe ( ebi . yh ) ;
29+ expect ( di . ys ) . toBe ( ebi . ys ) ;
30+ } ) ;
31+ }
32+
1833 it ( 'should autorange to the visible bars and remove invisible bars' , function ( done ) {
19- function check ( xrange , yrange , xcount , ycount ) {
34+ function check ( xrange , yrange , xCount , yCount ) {
2035 var xa = gd . _fullLayout . xaxis ;
2136 var ya = gd . _fullLayout . yaxis ;
2237 expect ( xa . range ) . toBeCloseToArray ( xrange , 3 ) ;
2338 expect ( ya . range ) . toBeCloseToArray ( yrange , 3 ) ;
2439
25- expect ( d3 . selectAll ( '.xerror' ) . size ( ) ) . toBe ( xcount ) ;
26- expect ( d3 . selectAll ( '.yerror' ) . size ( ) ) . toBe ( ycount ) ;
40+ countBars ( xCount , yCount ) ;
2741 }
2842 Plotly . newPlot ( gd , [ {
2943 y : [ 1 , 2 , 3 ] ,
@@ -50,4 +64,40 @@ describe('errorbar plotting', function() {
5064 . catch ( fail )
5165 . then ( done ) ;
5266 } ) ;
67+
68+ it ( 'shows half errorbars and removes individual bars that disappear' , function ( done ) {
69+ Plotly . newPlot ( gd , [ {
70+ x : [ 0 , 10 , 20 ] ,
71+ y : [ 30 , 40 , 50 ] ,
72+ error_x : { type : 'data' , array : [ 2 , 3 ] , visible : true , symmetric : false } ,
73+ error_y : { type : 'data' , arrayminus : [ 4 ] , visible : true , symmetric : false }
74+ } ] )
75+ . then ( function ( ) {
76+ countBars ( 2 , 1 ) ;
77+ checkCalcdata ( gd . calcdata [ 0 ] , [
78+ { xs : 0 , xh : 2 , ys : 26 , yh : 30 } ,
79+ { xs : 10 , xh : 13 }
80+ ] ) ;
81+
82+ Plotly . restyle ( gd , { 'error_x.array' : [ [ 1 ] ] , 'error_y.arrayminus' : [ [ 5 , 6 ] ] } ) ;
83+ } )
84+ . then ( function ( ) {
85+ countBars ( 1 , 2 ) ;
86+ checkCalcdata ( gd . calcdata [ 0 ] , [
87+ { xs : 0 , xh : 1 , ys : 25 , yh : 30 } ,
88+ { ys : 34 , yh : 40 }
89+ ] ) ;
90+
91+ Plotly . restyle ( gd , { 'error_x.array' : [ [ 7 , 8 ] ] , 'error_y.arrayminus' : [ [ 9 ] ] } ) ;
92+ } )
93+ . then ( function ( ) {
94+ countBars ( 2 , 1 ) ;
95+ checkCalcdata ( gd . calcdata [ 0 ] , [
96+ { xs : 0 , xh : 7 , ys : 21 , yh : 30 } ,
97+ { xs : 10 , xh : 18 }
98+ ] ) ;
99+ } )
100+ . catch ( fail )
101+ . then ( done ) ;
102+ } ) ;
53103} ) ;
0 commit comments