@@ -479,5 +479,53 @@ describe('Test histogram2d hover:', function() {
479
479
. catch ( failTest )
480
480
. then ( done ) ;
481
481
} ) ;
482
+
483
+ it ( 'shows the data range when bins have no value in it' , function ( done ) {
484
+ function _check ( msg , xpx , ypx , lines ) {
485
+ _hover ( xpx , ypx ) ;
486
+ assertHoverLabelContent ( { nums : lines . join ( '\n' ) } , msg ) ;
487
+ }
488
+
489
+ Plotly . newPlot ( 'graph' , [ {
490
+ type : 'histogram2d' ,
491
+ x : [ 18.78 ] ,
492
+ y : [ 3 ] ,
493
+ xbins : {
494
+ start : 0 ,
495
+ end : 55 ,
496
+ size : 5
497
+ } ,
498
+ ybins : {
499
+ start : 0 ,
500
+ end : 11 ,
501
+ size : 1
502
+ }
503
+ } ] , {
504
+ width : 400 ,
505
+ height : 400 ,
506
+ margin : { l : 0 , t : 0 , r : 0 , b : 0 }
507
+ } )
508
+ . then ( function ( ) {
509
+ expect ( gd . calcdata [ 0 ] [ 0 ] . xRanges ) . toBeCloseTo2DArray ( [
510
+ [ 0 , 4 ] , [ 5 , 9 ] , [ 10 , 14 ] ,
511
+ [ 18.78 , 18.78 ] ,
512
+ [ 20 , 24 ] , [ 25 , 29 ] , [ 30 , 34 ] ,
513
+ [ 35 , 39 ] , [ 40 , 44 ] , [ 45 , 49 ] , [ 50 , 54 ]
514
+ ] , 2 , 'x-bins with some spread' ) ;
515
+ expect ( gd . calcdata [ 0 ] [ 0 ] . yRanges ) . toBeCloseTo2DArray ( [
516
+ [ 0 , 0 ] , [ 1 , 1 ] , [ 2 , 2 ] , [ 3 , 3 ] , [ 4 , 4 ] , [ 5 , 5 ] ,
517
+ [ 6 , 6 ] , [ 7 , 7 ] , [ 8 , 8 ] , [ 9 , 9 ] , [ 10 , 10 ]
518
+ ] , 2 , 'y-bins with single values' ) ;
519
+
520
+ _check ( 'on pt (!)' , 100 , 275 , [ 'x: 18.78' , 'y: 3' , 'z: 1' ] ) ;
521
+ _check ( 'on x of pt, above it' , 100 , 200 , [ 'x: 18.78' , 'y: 5' , 'z: 0' ] ) ;
522
+ _check ( 'off left/top of pt' , 50 , 100 , [ 'x: 5 - 9' , 'y: 8' , 'z: 0' ] ) ;
523
+ _check ( 'off right/top of pt' , 300 , 100 , [ 'x: 50 - 54' , 'y: 8' , 'z: 0' ] ) ;
524
+ _check ( 'off left/bottom of pt' , 50 , 325 , [ 'x: 5 - 9' , 'y: 2' , 'z: 0' ] ) ;
525
+ _check ( 'off right/bottom of pt' , 300 , 325 , [ 'x: 50 - 54' , 'y: 2' , 'z: 0' ] ) ;
526
+ } )
527
+ . catch ( failTest )
528
+ . then ( done ) ;
529
+ } ) ;
482
530
} ) ;
483
531
} ) ;
0 commit comments