One-step ticks only when the axis spans five or less, counted from zero

This commit is contained in:
2026-12-01 17:29:05 -06:00
parent b6e9acd3ba
commit f7eb170e15
+1 -1
View File
@@ -440,7 +440,7 @@ export function ageShare(r: Reading, axis: string): Figure {
export function valueAxis(values: Iterable<number | null | undefined>) { export function valueAxis(values: Iterable<number | null | undefined>) {
const found = [...values].filter((v): v is number => v != null && Number.isFinite(v)); const found = [...values].filter((v): v is number => v != null && Number.isFinite(v));
const counts = found.every(Number.isInteger); const counts = found.every(Number.isInteger);
const narrow = found.length > 0 && Math.max(...found) - Math.min(...found) <= 5; const narrow = found.length > 0 && Math.max(...found) - Math.min(0, ...found) <= 5;
return { return {
type: 'linear' as const, type: 'linear' as const,
tickformat: counts ? 'd' : SHORT, tickformat: counts ? 'd' : SHORT,