@@ -381,6 +381,7 @@ function axisTextKy(
381
381
dx : anchor === "left" ? + dx - tickSize - tickPadding + + insetLeft : + dx + + tickSize + + tickPadding - insetRight
382
382
} ,
383
383
function ( scale , ticks , channels ) {
384
+ if ( scale . type === "linear-integer" && tickFormat === undefined ) tickFormat = "d" ;
384
385
if ( fontVariant === undefined ) this . fontVariant = inferFontVariant ( scale ) ;
385
386
if ( text === undefined ) channels . text = inferTextChannel ( scale , ticks , tickFormat ) ;
386
387
}
@@ -428,6 +429,7 @@ function axisTextKx(
428
429
dy : anchor === "bottom" ? + dy + + tickSize + + tickPadding - insetBottom : + dy - tickSize - tickPadding + + insetTop
429
430
} ,
430
431
function ( scale , ticks , channels ) {
432
+ if ( scale . type === "linear-integer" && tickFormat === undefined ) tickFormat = "d" ;
431
433
if ( fontVariant === undefined ) this . fontVariant = inferFontVariant ( scale ) ;
432
434
if ( text === undefined ) channels . text = inferTextChannel ( scale , ticks , tickFormat ) ;
433
435
}
@@ -505,12 +507,17 @@ function axisMark(mark, k, ariaLabel, data, options, initialize) {
505
507
if ( ! scale ) throw new Error ( `missing scale: ${ k } ` ) ;
506
508
let { ticks, tickSpacing, interval} = options ;
507
509
if ( isTemporalScale ( scale ) && typeof ticks === "string" ) ( interval = ticks ) , ( ticks = undefined ) ;
510
+
511
+ const tickFunction =
512
+ scale . type === "linear-integer"
513
+ ? ( ticks ) => scale . ticks ( ticks ) . filter ( ( d ) => d === Math . floor ( d ) )
514
+ : scale . ticks ;
508
515
if ( data == null ) {
509
516
if ( isIterable ( ticks ) ) {
510
517
data = arrayify ( ticks ) ;
511
518
} else if ( scale . ticks ) {
512
519
if ( ticks !== undefined ) {
513
- data = scale . ticks ( ticks ) ;
520
+ data = tickFunction ( ticks ) ;
514
521
} else {
515
522
interval = maybeInterval ( interval === undefined ? scale . interval : interval , scale . type ) ;
516
523
if ( interval !== undefined ) {
@@ -523,7 +530,7 @@ function axisMark(mark, k, ariaLabel, data, options, initialize) {
523
530
} else {
524
531
const [ min , max ] = extent ( scale . range ( ) ) ;
525
532
ticks = ( max - min ) / ( tickSpacing === undefined ? ( k === "x" ? 80 : 35 ) : tickSpacing ) ;
526
- data = scale . ticks ( ticks ) ;
533
+ data = tickFunction ( ticks ) ;
527
534
}
528
535
}
529
536
} else {
0 commit comments