@@ -401,14 +401,43 @@ it("log.tickFormat(count, format) returns a filtered format", () => {
401
401
402
402
it ( "log.tickFormat(count, specifier) returns a filtered format" , ( ) => {
403
403
const x = scaleLog ( ) . domain ( [ 1000.1 , 1 ] ) ;
404
- assert . deepStrictEqual ( x . ticks ( ) . map ( x . tickFormat ( 10 , ".1s " ) ) , [
404
+ assert . deepStrictEqual ( x . ticks ( ) . map ( x . tickFormat ( 10 , "s " ) ) , [
405
405
"1k" ,
406
406
"" , "" , "" , "" , "" , "" , "300" , "200" , "100" ,
407
407
"" , "" , "" , "" , "" , "" , "30" , "20" , "10" ,
408
408
"" , "" , "" , "" , "" , "" , "3" , "2" , "1"
409
409
] ) ;
410
410
} ) ;
411
411
412
+ it ( "log.tickFormat(count, specifier) trims trailing zeroes by default" , ( ) => {
413
+ const x = scaleLog ( ) . domain ( [ 100.1 , 0.02 ] ) ;
414
+ assert . deepStrictEqual ( x . ticks ( ) . map ( x . tickFormat ( 10 , "f" ) ) , [
415
+ "100" ,
416
+ "" , "" , "" , "" , "" , "" , "" , "20" , "10" ,
417
+ "" , "" , "" , "" , "" , "" , "" , "2" , "1" ,
418
+ "" , "" , "" , "" , "" , "" , "" , "0.2" , "0.1" ,
419
+ "" , "" , "" , "" , "" , "" , "" , "0.02"
420
+ ] ) ;
421
+ } ) ;
422
+
423
+ it ( "log.tickFormat(count, specifier) with base two trims trailing zeroes by default" , ( ) => {
424
+ const x = scaleLog ( ) . base ( 2 ) . domain ( [ 100.1 , 0.02 ] ) ;
425
+ assert . deepStrictEqual ( x . ticks ( ) . map ( x . tickFormat ( 10 , "f" ) ) , [
426
+ "64" , "32" , "16" , "8" , "4" , "2" , "1" , "0.5" , "0.25" , "0.125" , "0.0625" , "0.03125"
427
+ ] ) ;
428
+ } ) ;
429
+
430
+ it ( "log.tickFormat(count, specifier) preserves trailing zeroes if needed" , ( ) => {
431
+ const x = scaleLog ( ) . domain ( [ 100.1 , 0.02 ] ) ;
432
+ assert . deepStrictEqual ( x . ticks ( ) . map ( x . tickFormat ( 10 , ".1f" ) ) , [
433
+ "100.0" ,
434
+ "" , "" , "" , "" , "" , "" , "" , "20.0" , "10.0" ,
435
+ "" , "" , "" , "" , "" , "" , "" , "2.0" , "1.0" ,
436
+ "" , "" , "" , "" , "" , "" , "" , "0.2" , "0.1" ,
437
+ "" , "" , "" , "" , "" , "" , "" , "0.0"
438
+ ] ) ;
439
+ } ) ;
440
+
412
441
it ( "log.ticks() returns the empty array when the domain is degenerate" , ( ) => {
413
442
const x = scaleLog ( ) ;
414
443
assert . deepStrictEqual ( x . domain ( [ 0 , 1 ] ) . ticks ( ) , [ ] ) ;
0 commit comments