diff --git a/types/chart.js/chart.js-tests.ts b/types/chart.js/chart.js-tests.ts index 6a1bc49819..4f1b48017d 100644 --- a/types/chart.js/chart.js-tests.ts +++ b/types/chart.js/chart.js-tests.ts @@ -68,7 +68,21 @@ const chart: Chart = new Chart(ctx, { xAxes: [ { ticks: { - callback: Math.floor, + callback: (value) => { + if (value === 10) { + return Math.floor(value); + } + + if (value === 20) { + return `${value}`; + } + + if (value === 30) { + return undefined; + } + + return null; + }, sampleSize: 10, }, gridLines: { diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index e19f71e7be..7f67fefaa9 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -562,7 +562,10 @@ declare namespace Chart { backdropPaddingX?: number; backdropPaddingY?: number; beginAtZero?: boolean; - callback?(value: any, index: any, values: any): string | number; + /** + * If the callback returns null or undefined the associated grid line will be hidden. + */ + callback?(value: number | string, index: number, values: number[] | string[]): string | number | null | undefined; display?: boolean; fontColor?: ChartColor; fontFamily?: string;