@@ -5206,13 +5206,19 @@ describe('Test axes', function() {
5206
5206
5207
5207
afterEach ( destroyGraphDiv ) ;
5208
5208
5209
- function _assert ( msg , exp ) {
5209
+ function _assertPositions ( msg , exp ) {
5210
5210
var ax = gd . _fullLayout . xaxis ;
5211
- var labelPositions = ax . _vals . map ( function ( d ) { return ax . c2d ( d . periodX ) ; } ) ;
5212
- expect ( labelPositions ) . withContext ( msg ) . toEqual ( exp ) ;
5211
+ var positions = ax . _vals . map ( function ( d ) { return ax . c2d ( d . periodX ) ; } ) ;
5212
+ expect ( positions ) . withContext ( msg ) . toEqual ( exp ) ;
5213
5213
}
5214
5214
5215
- [ '%Y' , '%y' ] . forEach ( function ( tickformat ) {
5215
+ function _assertLabels ( msg , exp ) {
5216
+ var ax = gd . _fullLayout . xaxis ;
5217
+ var labels = ax . _vals . map ( function ( d ) { return d . text ; } ) ;
5218
+ expect ( labels ) . withContext ( msg ) . toEqual ( exp ) ;
5219
+ }
5220
+
5221
+ [ '%Y' , '%y' ] . forEach ( function ( tickformat , i ) {
5216
5222
it ( 'should respect yearly tickformat that includes ' + tickformat , function ( done ) {
5217
5223
Plotly . newPlot ( gd , {
5218
5224
data : [ {
@@ -5227,7 +5233,7 @@ describe('Test axes', function() {
5227
5233
}
5228
5234
} )
5229
5235
. then ( function ( ) {
5230
- _assert ( '' , [
5236
+ _assertPositions ( '' , [
5231
5237
'2019-07-02 15:00' ,
5232
5238
'2020-07-01 15:00' ,
5233
5239
'2021-07-02 15:00' ,
@@ -5238,6 +5244,12 @@ describe('Test axes', function() {
5238
5244
'2026-07-02 15:00'
5239
5245
] ) ;
5240
5246
} )
5247
+ . then ( function ( ) {
5248
+ _assertLabels ( '' , [
5249
+ [ '' , '2020' , '2021' , '2022' , '2023' , '2024' , '2025' , '' ] ,
5250
+ [ '' , '20' , '21' , '22' , '23' , '24' , '25' , '' ]
5251
+ ] [ i ] ) ;
5252
+ } )
5241
5253
. catch ( failTest )
5242
5254
. then ( done ) ;
5243
5255
} ) ;
@@ -5257,7 +5269,7 @@ describe('Test axes', function() {
5257
5269
}
5258
5270
} )
5259
5271
. then ( function ( ) {
5260
- _assert ( '' , [
5272
+ _assertPositions ( '' , [
5261
5273
'2019-11-15 15:45' ,
5262
5274
'2020-02-15 15:45' ,
5263
5275
'2020-05-16 15:45' ,
@@ -5270,11 +5282,14 @@ describe('Test axes', function() {
5270
5282
'2022-02-15 15:45'
5271
5283
] ) ;
5272
5284
} )
5285
+ . then ( function ( ) {
5286
+ _assertLabels ( '' , [ '' , '2020-1' , '2020-2' , '2020-3' , '2020-4' , '2021-1' , '2021-2' , '2021-3' , '2021-4' , '' ] ) ;
5287
+ } )
5273
5288
. catch ( failTest )
5274
5289
. then ( done ) ;
5275
5290
} ) ;
5276
5291
5277
- [ '%B' , '%b' , '%m' ] . forEach ( function ( tickformat ) {
5292
+ [ '%B' , '%b' , '%m' ] . forEach ( function ( tickformat , i ) {
5278
5293
it ( 'should respect monthly tickformat that includes ' + tickformat , function ( done ) {
5279
5294
Plotly . newPlot ( gd , {
5280
5295
data : [ {
@@ -5289,7 +5304,7 @@ describe('Test axes', function() {
5289
5304
}
5290
5305
} )
5291
5306
. then ( function ( ) {
5292
- _assert ( '' , [
5307
+ _assertPositions ( '' , [
5293
5308
'2019-12-16 05:15' ,
5294
5309
'2020-01-16 05:15' ,
5295
5310
'2020-02-16 05:15' ,
@@ -5300,6 +5315,13 @@ describe('Test axes', function() {
5300
5315
'2020-07-16 05:15'
5301
5316
] ) ;
5302
5317
} )
5318
+ . then ( function ( ) {
5319
+ _assertLabels ( '' , [
5320
+ [ '' , '1-January' , '1-February' , '1-March' , '2-April' , '2-May' , '2-June' , '' ] ,
5321
+ [ '' , '1-Jan' , '1-Feb' , '1-Mar' , '2-Apr' , '2-May' , '2-Jun' , '' ] ,
5322
+ [ '' , '1-01' , '1-02' , '1-03' , '2-04' , '2-05' , '2-06' , '' ]
5323
+ ] [ i ] ) ;
5324
+ } )
5303
5325
. catch ( failTest )
5304
5326
. then ( done ) ;
5305
5327
} ) ;
@@ -5319,7 +5341,7 @@ describe('Test axes', function() {
5319
5341
}
5320
5342
} )
5321
5343
. then ( function ( ) {
5322
- _assert ( '' , [
5344
+ _assertPositions ( '' , [
5323
5345
'2020-01-29 12:00' ,
5324
5346
'2020-02-05 12:00' ,
5325
5347
'2020-02-12 12:00' ,
@@ -5332,11 +5354,14 @@ describe('Test axes', function() {
5332
5354
'2020-04-01 12:00'
5333
5355
] ) ;
5334
5356
} )
5357
+ . then ( function ( ) {
5358
+ _assertLabels ( '' , [ 'Jan-04' , 'Feb-05' , 'Feb-06' , 'Feb-07' , 'Feb-08' , 'Mar-09' , 'Mar-10' , 'Mar-11' , 'Mar-12' , 'Mar-13' ] ) ;
5359
+ } )
5335
5360
. catch ( failTest )
5336
5361
. then ( done ) ;
5337
5362
} ) ;
5338
5363
5339
- [ '%V' , '%W' ] . forEach ( function ( tickformat ) {
5364
+ [ '%V' , '%W' ] . forEach ( function ( tickformat , i ) {
5340
5365
it ( 'should respect Monday-based week tickformat that includes ' + tickformat , function ( done ) {
5341
5366
Plotly . newPlot ( gd , {
5342
5367
data : [ {
@@ -5351,7 +5376,7 @@ describe('Test axes', function() {
5351
5376
}
5352
5377
} )
5353
5378
. then ( function ( ) {
5354
- _assert ( '' , [
5379
+ _assertPositions ( '' , [
5355
5380
'2020-01-30 12:00' ,
5356
5381
'2020-02-06 12:00' ,
5357
5382
'2020-02-13 12:00' ,
@@ -5364,12 +5389,18 @@ describe('Test axes', function() {
5364
5389
'2020-04-02 12:00'
5365
5390
] ) ;
5366
5391
} )
5392
+ . then ( function ( ) {
5393
+ _assertLabels ( '' , [
5394
+ [ 'Jan-05' , 'Feb-06' , 'Feb-07' , 'Feb-08' , 'Feb-09' , 'Mar-10' , 'Mar-11' , 'Mar-12' , 'Mar-13' , 'Mar-14' ] ,
5395
+ [ 'Jan-04' , 'Feb-05' , 'Feb-06' , 'Feb-07' , 'Feb-08' , 'Mar-09' , 'Mar-10' , 'Mar-11' , 'Mar-12' , 'Mar-13' ]
5396
+ ] [ i ] ) ;
5397
+ } )
5367
5398
. catch ( failTest )
5368
5399
. then ( done ) ;
5369
5400
} ) ;
5370
5401
} ) ;
5371
5402
5372
- [ '%A' , '%a' , '%d' , '%e' , '%j' , '%u' , '%w' , '%x' ] . forEach ( function ( tickformat ) {
5403
+ [ '%A' , '%a' , '%d' , '%e' , '%j' , '%u' , '%w' , '%x' ] . forEach ( function ( tickformat , i ) {
5373
5404
it ( 'should respect daily tickformat that includes ' + tickformat , function ( done ) {
5374
5405
Plotly . newPlot ( gd , {
5375
5406
data : [ {
@@ -5384,7 +5415,7 @@ describe('Test axes', function() {
5384
5415
}
5385
5416
} )
5386
5417
. then ( function ( ) {
5387
- _assert ( '' , [
5418
+ _assertPositions ( '' , [
5388
5419
'2019-12-31 12:00' ,
5389
5420
'2020-01-01 12:00' ,
5390
5421
'2020-01-02 12:00' ,
@@ -5396,12 +5427,24 @@ describe('Test axes', function() {
5396
5427
'2020-01-08 12:00'
5397
5428
] ) ;
5398
5429
} )
5430
+ . then ( function ( ) {
5431
+ _assertLabels ( '' , [
5432
+ [ '' , 'Jan-Wednesday' , 'Jan-Thursday' , 'Jan-Friday' , 'Jan-Saturday' , 'Jan-Sunday' , 'Jan-Monday' , 'Jan-Tuesday' , '' ] ,
5433
+ [ '' , 'Jan-Wed' , 'Jan-Thu' , 'Jan-Fri' , 'Jan-Sat' , 'Jan-Sun' , 'Jan-Mon' , 'Jan-Tue' , '' ] ,
5434
+ [ '' , 'Jan-01' , 'Jan-02' , 'Jan-03' , 'Jan-04' , 'Jan-05' , 'Jan-06' , 'Jan-07' , '' ] ,
5435
+ [ '' , 'Jan- 1' , 'Jan- 2' , 'Jan- 3' , 'Jan- 4' , 'Jan- 5' , 'Jan- 6' , 'Jan- 7' , '' ] ,
5436
+ [ '' , 'Jan-001' , 'Jan-002' , 'Jan-003' , 'Jan-004' , 'Jan-005' , 'Jan-006' , 'Jan-007' , '' ] ,
5437
+ [ '' , 'Jan-3' , 'Jan-4' , 'Jan-5' , 'Jan-6' , 'Jan-7' , 'Jan-1' , 'Jan-2' , '' ] ,
5438
+ [ '' , 'Jan-3' , 'Jan-4' , 'Jan-5' , 'Jan-6' , 'Jan-0' , 'Jan-1' , 'Jan-2' , '' ] ,
5439
+ [ '' , 'Jan-01/01/2020' , 'Jan-01/02/2020' , 'Jan-01/03/2020' , 'Jan-01/04/2020' , 'Jan-01/05/2020' , 'Jan-01/06/2020' , 'Jan-01/07/2020' , '' ]
5440
+ ] [ i ] ) ;
5441
+ } )
5399
5442
. catch ( failTest )
5400
5443
. then ( done ) ;
5401
5444
} ) ;
5402
5445
} ) ;
5403
5446
5404
- [ '%f' , '%L' , '%Q' , '%s' , '%S' , '%M' , '%H' , '%I' , '%p' , '%X' ] . forEach ( function ( tickformat ) {
5447
+ [ '%f' , '%L' , '%Q' , '%s' , '%S' , '%M' , '%H' , '%I' , '%p' , '%X' ] . forEach ( function ( tickformat , i ) {
5405
5448
it ( 'should respect daily tickformat that includes ' + tickformat , function ( done ) {
5406
5449
Plotly . newPlot ( gd , {
5407
5450
data : [ {
@@ -5416,7 +5459,7 @@ describe('Test axes', function() {
5416
5459
}
5417
5460
} )
5418
5461
. then ( function ( ) {
5419
- _assert ( '' , [
5462
+ _assertPositions ( '' , [
5420
5463
'2019-12-31 21:00' ,
5421
5464
'2020-01-01' ,
5422
5465
'2020-01-01 03:00' ,
@@ -5429,6 +5472,20 @@ describe('Test axes', function() {
5429
5472
'2020-01-02'
5430
5473
] ) ;
5431
5474
} )
5475
+ . then ( function ( ) {
5476
+ _assertLabels ( '' , [
5477
+ [ '' , 'Wed-0' , 'Wed-0' , 'Wed-0' , 'Wed-0' , 'Wed-0' , 'Wed-0' , 'Wed-0' , 'Wed-0' , 'Thu-0' ] ,
5478
+ [ '' , 'Wed-000' , 'Wed-000' , 'Wed-000' , 'Wed-000' , 'Wed-000' , 'Wed-000' , 'Wed-000' , 'Wed-000' , 'Thu-000' ] ,
5479
+ [ '' , 'Wed-1577836800000' , 'Wed-1577847600000' , 'Wed-1577858400000' , 'Wed-1577869200000' , 'Wed-1577880000000' , 'Wed-1577890800000' , 'Wed-1577901600000' , 'Wed-1577912400000' , 'Thu-1577923200000' ] ,
5480
+ [ '' , 'Wed-1577836800' , 'Wed-1577847600' , 'Wed-1577858400' , 'Wed-1577869200' , 'Wed-1577880000' , 'Wed-1577890800' , 'Wed-1577901600' , 'Wed-1577912400' , 'Thu-1577923200' ] ,
5481
+ [ '' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Thu-00' ] ,
5482
+ [ '' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Wed-00' , 'Thu-00' ] ,
5483
+ [ '' , 'Wed-00' , 'Wed-03' , 'Wed-06' , 'Wed-09' , 'Wed-12' , 'Wed-15' , 'Wed-18' , 'Wed-21' , 'Thu-00' ] ,
5484
+ [ '' , 'Wed-12' , 'Wed-03' , 'Wed-06' , 'Wed-09' , 'Wed-12' , 'Wed-03' , 'Wed-06' , 'Wed-09' , 'Thu-12' ] ,
5485
+ [ '' , 'Wed-AM' , 'Wed-AM' , 'Wed-AM' , 'Wed-AM' , 'Wed-PM' , 'Wed-PM' , 'Wed-PM' , 'Wed-PM' , 'Thu-AM' ] ,
5486
+ [ '' , 'Wed-00:00:00' , 'Wed-03:00:00' , 'Wed-06:00:00' , 'Wed-09:00:00' , 'Wed-12:00:00' , 'Wed-15:00:00' , 'Wed-18:00:00' , 'Wed-21:00:00' , 'Thu-00:00:00' ]
5487
+ ] [ i ] ) ;
5488
+ } )
5432
5489
. catch ( failTest )
5433
5490
. then ( done ) ;
5434
5491
} ) ;
0 commit comments