@@ -5206,13 +5206,19 @@ describe('Test axes', function() {
52065206
52075207 afterEach ( destroyGraphDiv ) ;
52085208
5209- function _assert ( msg , exp ) {
5209+ function _assertPositions ( msg , exp ) {
52105210 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 ) ;
52135213 }
52145214
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 ) {
52165222 it ( 'should respect yearly tickformat that includes ' + tickformat , function ( done ) {
52175223 Plotly . newPlot ( gd , {
52185224 data : [ {
@@ -5227,7 +5233,7 @@ describe('Test axes', function() {
52275233 }
52285234 } )
52295235 . then ( function ( ) {
5230- _assert ( '' , [
5236+ _assertPositions ( '' , [
52315237 '2019-07-02 15:00' ,
52325238 '2020-07-01 15:00' ,
52335239 '2021-07-02 15:00' ,
@@ -5238,6 +5244,12 @@ describe('Test axes', function() {
52385244 '2026-07-02 15:00'
52395245 ] ) ;
52405246 } )
5247+ . then ( function ( ) {
5248+ _assertLabels ( '' , [
5249+ [ '' , '2020' , '2021' , '2022' , '2023' , '2024' , '2025' , '' ] ,
5250+ [ '' , '20' , '21' , '22' , '23' , '24' , '25' , '' ]
5251+ ] [ i ] ) ;
5252+ } )
52415253 . catch ( failTest )
52425254 . then ( done ) ;
52435255 } ) ;
@@ -5257,7 +5269,7 @@ describe('Test axes', function() {
52575269 }
52585270 } )
52595271 . then ( function ( ) {
5260- _assert ( '' , [
5272+ _assertPositions ( '' , [
52615273 '2019-11-15 15:45' ,
52625274 '2020-02-15 15:45' ,
52635275 '2020-05-16 15:45' ,
@@ -5270,11 +5282,14 @@ describe('Test axes', function() {
52705282 '2022-02-15 15:45'
52715283 ] ) ;
52725284 } )
5285+ . then ( function ( ) {
5286+ _assertLabels ( '' , [ '' , '2020-1' , '2020-2' , '2020-3' , '2020-4' , '2021-1' , '2021-2' , '2021-3' , '2021-4' , '' ] ) ;
5287+ } )
52735288 . catch ( failTest )
52745289 . then ( done ) ;
52755290 } ) ;
52765291
5277- [ '%B' , '%b' , '%m' ] . forEach ( function ( tickformat ) {
5292+ [ '%B' , '%b' , '%m' ] . forEach ( function ( tickformat , i ) {
52785293 it ( 'should respect monthly tickformat that includes ' + tickformat , function ( done ) {
52795294 Plotly . newPlot ( gd , {
52805295 data : [ {
@@ -5289,7 +5304,7 @@ describe('Test axes', function() {
52895304 }
52905305 } )
52915306 . then ( function ( ) {
5292- _assert ( '' , [
5307+ _assertPositions ( '' , [
52935308 '2019-12-16 05:15' ,
52945309 '2020-01-16 05:15' ,
52955310 '2020-02-16 05:15' ,
@@ -5300,6 +5315,13 @@ describe('Test axes', function() {
53005315 '2020-07-16 05:15'
53015316 ] ) ;
53025317 } )
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+ } )
53035325 . catch ( failTest )
53045326 . then ( done ) ;
53055327 } ) ;
@@ -5319,7 +5341,7 @@ describe('Test axes', function() {
53195341 }
53205342 } )
53215343 . then ( function ( ) {
5322- _assert ( '' , [
5344+ _assertPositions ( '' , [
53235345 '2020-01-29 12:00' ,
53245346 '2020-02-05 12:00' ,
53255347 '2020-02-12 12:00' ,
@@ -5332,11 +5354,14 @@ describe('Test axes', function() {
53325354 '2020-04-01 12:00'
53335355 ] ) ;
53345356 } )
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+ } )
53355360 . catch ( failTest )
53365361 . then ( done ) ;
53375362 } ) ;
53385363
5339- [ '%V' , '%W' ] . forEach ( function ( tickformat ) {
5364+ [ '%V' , '%W' ] . forEach ( function ( tickformat , i ) {
53405365 it ( 'should respect Monday-based week tickformat that includes ' + tickformat , function ( done ) {
53415366 Plotly . newPlot ( gd , {
53425367 data : [ {
@@ -5351,7 +5376,7 @@ describe('Test axes', function() {
53515376 }
53525377 } )
53535378 . then ( function ( ) {
5354- _assert ( '' , [
5379+ _assertPositions ( '' , [
53555380 '2020-01-30 12:00' ,
53565381 '2020-02-06 12:00' ,
53575382 '2020-02-13 12:00' ,
@@ -5364,12 +5389,18 @@ describe('Test axes', function() {
53645389 '2020-04-02 12:00'
53655390 ] ) ;
53665391 } )
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+ } )
53675398 . catch ( failTest )
53685399 . then ( done ) ;
53695400 } ) ;
53705401 } ) ;
53715402
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 ) {
53735404 it ( 'should respect daily tickformat that includes ' + tickformat , function ( done ) {
53745405 Plotly . newPlot ( gd , {
53755406 data : [ {
@@ -5384,7 +5415,7 @@ describe('Test axes', function() {
53845415 }
53855416 } )
53865417 . then ( function ( ) {
5387- _assert ( '' , [
5418+ _assertPositions ( '' , [
53885419 '2019-12-31 12:00' ,
53895420 '2020-01-01 12:00' ,
53905421 '2020-01-02 12:00' ,
@@ -5396,12 +5427,24 @@ describe('Test axes', function() {
53965427 '2020-01-08 12:00'
53975428 ] ) ;
53985429 } )
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+ } )
53995442 . catch ( failTest )
54005443 . then ( done ) ;
54015444 } ) ;
54025445 } ) ;
54035446
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 ) {
54055448 it ( 'should respect daily tickformat that includes ' + tickformat , function ( done ) {
54065449 Plotly . newPlot ( gd , {
54075450 data : [ {
@@ -5416,7 +5459,7 @@ describe('Test axes', function() {
54165459 }
54175460 } )
54185461 . then ( function ( ) {
5419- _assert ( '' , [
5462+ _assertPositions ( '' , [
54205463 '2019-12-31 21:00' ,
54215464 '2020-01-01' ,
54225465 '2020-01-01 03:00' ,
@@ -5429,6 +5472,20 @@ describe('Test axes', function() {
54295472 '2020-01-02'
54305473 ] ) ;
54315474 } )
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+ } )
54325489 . catch ( failTest )
54335490 . then ( done ) ;
54345491 } ) ;
0 commit comments