@@ -15,15 +15,29 @@ describe('errorbar plotting', function() {
15
15
16
16
afterEach ( destroyGraphDiv ) ;
17
17
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
+
18
33
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 ) {
20
35
var xa = gd . _fullLayout . xaxis ;
21
36
var ya = gd . _fullLayout . yaxis ;
22
37
expect ( xa . range ) . toBeCloseToArray ( xrange , 3 ) ;
23
38
expect ( ya . range ) . toBeCloseToArray ( yrange , 3 ) ;
24
39
25
- expect ( d3 . selectAll ( '.xerror' ) . size ( ) ) . toBe ( xcount ) ;
26
- expect ( d3 . selectAll ( '.yerror' ) . size ( ) ) . toBe ( ycount ) ;
40
+ countBars ( xCount , yCount ) ;
27
41
}
28
42
Plotly . newPlot ( gd , [ {
29
43
y : [ 1 , 2 , 3 ] ,
@@ -50,4 +64,40 @@ describe('errorbar plotting', function() {
50
64
. catch ( fail )
51
65
. then ( done ) ;
52
66
} ) ;
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
+ } ) ;
53
103
} ) ;
0 commit comments