@@ -5377,80 +5377,132 @@ describe('hovermode: (x|y)unified', function() {
5377
5377
. then ( function ( gd ) {
5378
5378
_hover ( gd , { xpx : 40 , ypx : 200 } ) ;
5379
5379
assertLabel ( { title : 'Jan' , items : [
5380
- 'bar : (Jan 1, 2000, 1)' ,
5381
- 'start : 1' ,
5382
- 'end : 1'
5380
+ 'start : 1'
5383
5381
] } ) ;
5384
5382
5385
5383
_hover ( gd , { xpx : 100 , ypx : 200 } ) ;
5384
+ assertLabel ( { title : 'Jan 1, 2000' , items : [
5385
+ 'bar : 1'
5386
+ ] } ) ;
5387
+
5388
+ _hover ( gd , { xpx : 210 , ypx : 200 } ) ;
5386
5389
assertLabel ( { title : 'Jan' , items : [
5387
5390
'bar : (Jan 1, 2000, 1)' ,
5388
- 'start : 1 ' ,
5389
- 'end : 1'
5391
+ 'start : (Feb, 2) ' ,
5392
+ 'end : 1' ,
5390
5393
] } ) ;
5391
5394
5392
5395
_hover ( gd , { xpx : 360 , ypx : 200 } ) ;
5393
- assertLabel ( { title : 'Feb' , items : [
5394
- 'bar : (Feb 1, 2000, 2)' ,
5395
- 'start : 2' ,
5396
- 'end : 2'
5396
+ assertLabel ( { title : 'Feb 1, 2000' , items : [
5397
+ 'bar : 2'
5397
5398
] } ) ;
5398
5399
5399
5400
_hover ( gd , { xpx : 400 , ypx : 200 } ) ;
5400
5401
assertLabel ( { title : 'Feb' , items : [
5401
5402
'bar : (Feb 1, 2000, 2)' ,
5402
- 'start : 2' ,
5403
5403
'end : 2'
5404
5404
] } ) ;
5405
5405
} )
5406
5406
. then ( done , done . fail ) ;
5407
5407
} ) ;
5408
5408
} ) ;
5409
5409
5410
- it ( 'two end positioned scatter period' , function ( done ) {
5411
- var fig = {
5412
- data : [ {
5413
- x : [
5414
- '1970-01-01' ,
5415
- '1970-07-01' ,
5416
- '1971-01-01'
5417
- ] ,
5418
- xperiod : 'M6' ,
5419
- xperiodalignment : 'end' ,
5420
- y : [ 1 , 2 , 3 ]
5421
- } , {
5422
- x : [
5423
- '1970-01-01' ,
5424
- '1970-07-01' ,
5425
- '1971-01-01' ,
5426
- ] ,
5427
- xperiod : 'M6' ,
5428
- xperiodalignment : 'end' ,
5429
- y : [ 11 , 12 , 13 ]
5430
- } ] ,
5431
- layout : {
5432
- showlegend : false ,
5433
- width : 600 ,
5434
- height : 400 ,
5435
- hovermode : 'x unified'
5436
- }
5437
- } ;
5410
+ [ {
5411
+ type : 'scatter' ,
5412
+ alignment : 'start'
5413
+ } , {
5414
+ type : 'scatter' ,
5415
+ alignment : 'middle'
5416
+ } , {
5417
+ type : 'scatter' ,
5418
+ alignment : 'end'
5419
+ } , {
5420
+ type : 'bar' ,
5421
+ barmode : 'overlay' ,
5422
+ alignment : 'start'
5423
+ } , {
5424
+ type : 'bar' ,
5425
+ barmode : 'group' ,
5426
+ alignment : 'middle'
5427
+ } , {
5428
+ type : 'bar' ,
5429
+ barmode : 'group' ,
5430
+ alignment : 'end'
5431
+ } , {
5432
+ type : 'bar' ,
5433
+ barmode : 'group' ,
5434
+ alignment : 'start'
5435
+ } , {
5436
+ type : 'bar' ,
5437
+ barmode : 'overlay' ,
5438
+ alignment : 'middle'
5439
+ } , {
5440
+ type : 'bar' ,
5441
+ barmode : 'overlay' ,
5442
+ alignment : 'end'
5443
+ } , {
5444
+ type : 'bar' ,
5445
+ barmode : 'stacked' ,
5446
+ alignment : 'start'
5447
+ } , {
5448
+ type : 'bar' ,
5449
+ barmode : 'stacked' ,
5450
+ alignment : 'middle'
5451
+ } , {
5452
+ type : 'bar' ,
5453
+ barmode : 'stacked' ,
5454
+ alignment : 'end'
5455
+ } ] . forEach ( function ( t ) {
5456
+ it ( 'two ' + t . alignment + ' period positioned ' + ( t . barmode ? t . barmode + ' ' : '' ) + t . type + 's' , function ( done ) {
5457
+ var fig = {
5458
+ data : [ {
5459
+ x : [
5460
+ '1970-01-01' ,
5461
+ '1970-07-01' ,
5462
+ '1971-01-01'
5463
+ ] ,
5464
+ xperiod : 'M6' ,
5465
+ xperiodalignment : t . alignment ,
5466
+ type : t . type ,
5467
+ hovertemplate : '%{y}' ,
5468
+ y : [ 11 , 12 , 13 ]
5469
+ } , {
5470
+ x : [
5471
+ '1970-01-01' ,
5472
+ '1970-07-01' ,
5473
+ '1971-01-01' ,
5474
+ ] ,
5475
+ xperiod : 'M6' ,
5476
+ xperiodalignment : t . alignment ,
5477
+ type : t . type ,
5478
+ hovertemplate : '%{y}' ,
5479
+ y : [ 1 , 2 , 3 ]
5480
+ } ] ,
5481
+ layout : {
5482
+ barmode : t . barmode ,
5483
+ showlegend : false ,
5484
+ width : 600 ,
5485
+ height : 400 ,
5486
+ hovermode : 'x unified'
5487
+ }
5488
+ } ;
5438
5489
5439
- Plotly . newPlot ( gd , fig )
5440
- . then ( function ( gd ) {
5441
- _hover ( gd , { xpx : 200 , ypx : 200 } ) ;
5442
- assertLabel ( { title : 'Jul 1, 1970' , items : [
5443
- 'trace 0 : 2 ' ,
5444
- 'trace 1 : 12 '
5445
- ] } ) ;
5490
+ Plotly . newPlot ( gd , fig )
5491
+ . then ( function ( gd ) {
5492
+ _hover ( gd , { xpx : 200 , ypx : 200 } ) ;
5493
+ assertLabel ( { title : 'Jul 1, 1970' , items : [
5494
+ 'trace 0 : 12 ' ,
5495
+ 'trace 1 : 2 '
5496
+ ] } ) ;
5446
5497
5447
- _hover ( gd , { xpx : 400 , ypx : 200 } ) ;
5448
- assertLabel ( { title : 'Jan 1, 1971' , items : [
5449
- 'trace 0 : 3' ,
5450
- 'trace 1 : 13'
5451
- ] } ) ;
5452
- } )
5453
- . then ( done , done . fail ) ;
5498
+ _hover ( gd , { xpx : 400 , ypx : 200 } ) ;
5499
+ assertLabel ( { title : 'Jan 1, 1971' , items : [
5500
+ 'trace 0 : 13' ,
5501
+ 'trace 1 : 3'
5502
+ ] } ) ;
5503
+ } )
5504
+ . then ( done , done . fail ) ;
5505
+ } ) ;
5454
5506
} ) ;
5455
5507
5456
5508
it ( 'period with hover distance -1 include closest not farthest' , function ( done ) {
0 commit comments