@@ -2026,75 +2026,24 @@ describe('A bar plot', function() {
2026
2026
. then ( done ) ;
2027
2027
} ) ;
2028
2028
2029
- it ( 'should show up narrow bars as thin bars' , function ( done ) {
2030
- var mock = Lib . extendDeep ( { } , require ( '@mocks/bar_show_narrow.json' ) ) ;
2031
-
2032
- function getArea ( path ) {
2033
- var pos = path
2034
- . substr ( 1 , path . length - 2 )
2035
- . replace ( 'V' , ',' )
2036
- . replace ( 'H' , ',' )
2037
- . replace ( 'V' , ',' )
2038
- . split ( ',' ) ;
2039
- var dx = + pos [ 0 ] ;
2040
- var dy = + pos [ 1 ] ;
2041
- dy -= + pos [ 2 ] ;
2042
- dx -= + pos [ 3 ] ;
2043
-
2044
- return Math . abs ( dx * dy ) ;
2045
- }
2046
-
2047
- Plotly . plot ( gd , mock )
2048
- . then ( function ( ) {
2049
- var nodes = gd . querySelectorAll ( 'g.point > path' ) ;
2050
- expect ( nodes . length ) . toBe ( 16 , '# of bars' ) ;
2051
-
2052
- [
2053
- [ 0 , true ] ,
2054
- [ 1 , true ] ,
2055
- [ 2 , true ] ,
2056
- [ 3 , true ] ,
2057
- [ 4 , true ] ,
2058
- [ 5 , true ] ,
2059
- [ 6 , true ] ,
2060
- [ 7 , true ] ,
2061
- [ 8 , true ] ,
2062
- [ 9 , true ] ,
2063
- [ 10 , true ] ,
2064
- [ 11 , true ] ,
2065
- [ 12 , true ] ,
2066
- [ 13 , true ] ,
2067
- [ 14 , true ] ,
2068
- [ 15 , true ]
2069
- ] . forEach ( function ( e ) {
2070
- var i = e [ 0 ] ;
2071
- var d = nodes [ i ] . getAttribute ( 'd' ) ;
2072
- var visible = e [ 1 ] ;
2073
- expect ( getArea ( d ) > 0 ) . toBe ( visible , 'item:' + i ) ;
2074
- } ) ;
2075
- } )
2076
- . catch ( failTest )
2077
- . then ( done ) ;
2078
- } ) ;
2029
+ function getArea ( path ) {
2030
+ var pos = path
2031
+ . substr ( 1 , path . length - 2 )
2032
+ . replace ( 'V' , ',' )
2033
+ . replace ( 'H' , ',' )
2034
+ . replace ( 'V' , ',' )
2035
+ . split ( ',' ) ;
2036
+ var dx = + pos [ 0 ] ;
2037
+ var dy = + pos [ 1 ] ;
2038
+ dy -= + pos [ 2 ] ;
2039
+ dx -= + pos [ 3 ] ;
2040
+
2041
+ return Math . abs ( dx * dy ) ;
2042
+ }
2079
2043
2080
2044
it ( 'should not show up null and zero bars as thin bars' , function ( done ) {
2081
2045
var mock = Lib . extendDeep ( { } , require ( '@mocks/bar_hide_nulls.json' ) ) ;
2082
2046
2083
- function getArea ( path ) {
2084
- var pos = path
2085
- . substr ( 1 , path . length - 2 )
2086
- . replace ( 'V' , ',' )
2087
- . replace ( 'H' , ',' )
2088
- . replace ( 'V' , ',' )
2089
- . split ( ',' ) ;
2090
- var dx = + pos [ 0 ] ;
2091
- var dy = + pos [ 1 ] ;
2092
- dy -= + pos [ 2 ] ;
2093
- dx -= + pos [ 3 ] ;
2094
-
2095
- return Math . abs ( dx * dy ) ;
2096
- }
2097
-
2098
2047
Plotly . plot ( gd , mock )
2099
2048
. then ( function ( ) {
2100
2049
var nodes = gd . querySelectorAll ( 'g.point > path' ) ;
@@ -2127,6 +2076,39 @@ describe('A bar plot', function() {
2127
2076
. catch ( failTest )
2128
2077
. then ( done ) ;
2129
2078
} ) ;
2079
+
2080
+ describe ( 'show narrow bars' , function ( ) {
2081
+ [ 'initial zoom' , 'after zoom out' ] . forEach ( function ( zoomStr ) {
2082
+ it ( zoomStr , function ( done ) {
2083
+ var mock = Lib . extendDeep ( { } , require ( '@mocks/bar_show_narrow.json' ) ) ;
2084
+
2085
+ if ( zoomStr === 'after zoom out' ) {
2086
+ mock . layout . xaxis . range = [ - 14.9 , 17.9 ] ;
2087
+ mock . layout . xaxis2 . range = [ 17.9 , - 14.9 ] ;
2088
+ mock . layout . xaxis3 . range = [ - 3.9 , 4.9 ] ;
2089
+ mock . layout . xaxis4 . range = [ 4.9 , - 3.9 ] ;
2090
+
2091
+ mock . layout . yaxis . range = [ - 3.9 , 4.9 ] ;
2092
+ mock . layout . yaxis2 . range = [ 4.9 , - 3.9 ] ;
2093
+ mock . layout . yaxis3 . range = [ - 14.9 , 17.9 ] ;
2094
+ mock . layout . yaxis4 . range = [ 17.9 , - 14.9 ] ;
2095
+ }
2096
+
2097
+ Plotly . plot ( gd , mock )
2098
+ . then ( function ( ) {
2099
+ var nodes = gd . querySelectorAll ( 'g.point > path' ) ;
2100
+ expect ( nodes . length ) . toBe ( 16 , '# of bars' ) ;
2101
+
2102
+ for ( var i = 0 ; i < 16 ; i ++ ) {
2103
+ var d = nodes [ i ] . getAttribute ( 'd' ) ;
2104
+ expect ( getArea ( d ) > 0 ) . toBe ( true , 'item:' + i ) ;
2105
+ }
2106
+ } )
2107
+ . catch ( failTest )
2108
+ . then ( done ) ;
2109
+ } ) ;
2110
+ } ) ;
2111
+ } ) ;
2130
2112
} ) ;
2131
2113
2132
2114
describe ( 'bar visibility toggling:' , function ( ) {
0 commit comments