From 25dcc2cabf7a40c5c10c33ade563d0fb0df9fa21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Mon, 13 Jan 2020 18:20:54 +0100 Subject: [PATCH] feat(chart.js): add 'sampleSize'. Closes #40775 (#41525) Thanks! --- types/chart.js/chart.js-tests.ts | 4 +++- types/chart.js/index.d.ts | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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;