@@ -283,6 +283,39 @@ describe('Bar.calc', function() {
283
283
var cd = gd . calcdata ;
284
284
assertPointField ( cd , 'b' , [ [ 0 , 1 , 2 ] , [ 0 , 1 , 0 ] , [ 0 , 0 ] ] ) ;
285
285
} ) ;
286
+
287
+ it ( 'should not exclude items with non-numeric x/y from calcdata' , function ( ) {
288
+ var gd = mockBarPlot ( [ {
289
+ x : [ 5 , NaN , 15 , 20 , null , 21 ] ,
290
+ y : [ 20 , NaN , 23 , 25 , null , 26 ]
291
+ } ] ) ;
292
+
293
+ var cd = gd . calcdata ;
294
+ assertPointField ( cd , 'x' , [ [ 5 , NaN , 15 , 20 , NaN , 21 ] ] ) ;
295
+ assertPointField ( cd , 'y' , [ [ 20 , NaN , 23 , 25 , NaN , 26 ] ] ) ;
296
+ } ) ;
297
+
298
+ it ( 'should not exclude items with non-numeric y from calcdata (to plots gaps correctly)' , function ( ) {
299
+ var gd = mockBarPlot ( [ {
300
+ x : [ 'a' , 'b' , 'c' , 'd' ] ,
301
+ y : [ 1 , null , 'nonsense' , 15 ]
302
+ } ] ) ;
303
+
304
+ var cd = gd . calcdata ;
305
+ assertPointField ( cd , 'x' , [ [ 0 , 1 , 2 , 3 ] ] ) ;
306
+ assertPointField ( cd , 'y' , [ [ 1 , NaN , NaN , 15 ] ] ) ;
307
+ } ) ;
308
+
309
+ it ( 'should not exclude items with non-numeric x from calcdata (to plots gaps correctly)' , function ( ) {
310
+ var gd = mockBarPlot ( [ {
311
+ x : [ 1 , null , 'nonsense' , 15 ] ,
312
+ y : [ 1 , 2 , 10 , 30 ]
313
+ } ] ) ;
314
+
315
+ var cd = gd . calcdata ;
316
+ assertPointField ( cd , 'x' , [ [ 1 , NaN , NaN , 15 ] ] ) ;
317
+ assertPointField ( cd , 'y' , [ [ 1 , 2 , 10 , 30 ] ] ) ;
318
+ } ) ;
286
319
} ) ;
287
320
288
321
describe ( 'Bar.setPositions' , function ( ) {
@@ -681,23 +714,6 @@ describe('Bar.setPositions', function() {
681
714
expect ( Axes . getAutoRange ( ya ) ) . toBeCloseToArray ( [ - 1.11 , 1.11 ] , undefined , '(ya.range)' ) ;
682
715
} ) ;
683
716
684
- it ( 'should skip placeholder trace in position computations' , function ( ) {
685
- var gd = mockBarPlot ( [ {
686
- x : [ 1 , 2 , 3 ] ,
687
- y : [ 2 , 1 , 2 ]
688
- } , {
689
- x : [ null ] ,
690
- y : [ null ]
691
- } ] ) ;
692
-
693
- expect ( gd . calcdata [ 0 ] [ 0 ] . t . barwidth ) . toEqual ( 0.8 ) ;
694
-
695
- expect ( gd . calcdata [ 1 ] [ 0 ] . x ) . toBe ( false ) ;
696
- expect ( gd . calcdata [ 1 ] [ 0 ] . y ) . toBe ( false ) ;
697
- expect ( gd . calcdata [ 1 ] [ 0 ] . placeholder ) . toBe ( true ) ;
698
- expect ( gd . calcdata [ 1 ] [ 0 ] . t . barwidth ) . toBeUndefined ( ) ;
699
- } ) ;
700
-
701
717
it ( 'works with log axes (grouped bars)' , function ( ) {
702
718
var gd = mockBarPlot ( [
703
719
{ y : [ 1 , 10 , 1e10 , - 1 ] } ,
@@ -1285,7 +1301,7 @@ function mockBarPlot(dataWithoutTraceType, layout) {
1285
1301
1286
1302
var gd = {
1287
1303
data : dataWithTraceType ,
1288
- layout : layout ,
1304
+ layout : layout || { } ,
1289
1305
calcdata : [ ]
1290
1306
} ;
1291
1307
0 commit comments