@@ -401,14 +401,43 @@ it("log.tickFormat(count, format) returns a filtered format", () => {
401401
402402it ( "log.tickFormat(count, specifier) returns a filtered format" , ( ) => {
403403 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 " ) ) , [
405405 "1k" ,
406406 "" , "" , "" , "" , "" , "" , "300" , "200" , "100" ,
407407 "" , "" , "" , "" , "" , "" , "30" , "20" , "10" ,
408408 "" , "" , "" , "" , "" , "" , "3" , "2" , "1"
409409 ] ) ;
410410} ) ;
411411
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+
412441it ( "log.ticks() returns the empty array when the domain is degenerate" , ( ) => {
413442 const x = scaleLog ( ) ;
414443 assert . deepStrictEqual ( x . domain ( [ 0 , 1 ] ) . ticks ( ) , [ ] ) ;
0 commit comments