From b5b112c87bf676c88d2de1c48bfa00a95528a791 Mon Sep 17 00:00:00 2001 From: "Mr.Dr.Professor Patrick" Date: Thu, 11 Apr 2024 10:54:45 +0200 Subject: [PATCH] fix(Highcharts plugin): fix `getXAxisThresholdValue` helper (#463) fix(Highcharts plugin): fix getXAxisThresholdValue helper --- .../helpers/config/utils/getXAxisThresholdValue.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.ts b/src/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.ts index 6df8d00e..ef5d1641 100644 --- a/src/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.ts +++ b/src/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.ts @@ -1,5 +1,7 @@ import type {Highcharts} from '../../../../types'; +const VALUES_LIMIT = 1000; + export const getXAxisThresholdValue = ( graphs: Record[], operation: 'min' | 'max', @@ -10,8 +12,18 @@ export const getXAxisThresholdValue = ( return [...acc, ...data.map((point: Highcharts.Point) => point.x)]; }, [] as number[]); const fn = operation === 'min' ? Math.min : Math.max; + let index = 0; + let limited = xAxisValues.slice(0, VALUES_LIMIT); + let xAxisValue; - const xAxisValue = fn(...xAxisValues); + do { + if (typeof xAxisValue === 'number') { + limited.push(xAxisValue); + } + xAxisValue = fn(...limited); + index += 1; + limited = xAxisValues.slice(index * VALUES_LIMIT, index * VALUES_LIMIT + VALUES_LIMIT); + } while (limited.length); return isFinite(xAxisValue) ? xAxisValue : null; };