diff --git a/types/chart.js/chart.js-tests.ts b/types/chart.js/chart.js-tests.ts index 6d38b51fd9..d4cb0b189e 100644 --- a/types/chart.js/chart.js-tests.ts +++ b/types/chart.js/chart.js-tests.ts @@ -68,6 +68,7 @@ const chart: Chart = new Chart(ctx, { { ticks: { callback: Math.floor, + sampleSize: 10, }, gridLines: { display: false, @@ -266,7 +267,8 @@ const linearScaleChart: Chart = new Chart(ctx, { distribution: 'series', ticks: { source: 'data', - autoSkip: true + autoSkip: true, + sampleSize: 1, } }], yAxes: [{ diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index 1c1396ae03..5793bfbf1e 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -563,6 +563,13 @@ declare namespace Chart { mirror?: boolean; padding?: number; reverse?: boolean; + /** + * The number of ticks to examine when deciding how many labels will fit. + * Setting a smaller value will be faster, but may be less accurate + * when there is large variability in label length. + * Deault: `ticks.length` + */ + sampleSize?: number; showLabelBackdrop?: boolean; source?: 'auto' | 'data' | 'labels'; stepSize?: number;