From 86a4e796649644cdad1f3d1077fb32b8f07b53e3 Mon Sep 17 00:00:00 2001 From: novykh Date: Mon, 13 Jan 2025 11:44:15 +0200 Subject: [PATCH] Fix conversion. --- src/helpers/unitConversion/index.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/helpers/unitConversion/index.js b/src/helpers/unitConversion/index.js index d42acfcd..bcb1b4b1 100644 --- a/src/helpers/unitConversion/index.js +++ b/src/helpers/unitConversion/index.js @@ -42,7 +42,13 @@ export default chart => { }) } - const offVisibleDimensionsChanged = chart.on("visibleDimensionsChanged", () => { + const onConvert = (ymin, ymax) => { + if (Array.isArray(chart.getAttribute("staticValueRange"))) { + const [min, max] = chart.getAttribute("staticValueRange") + convert(min, max) + return + } + const result = chart.getPayload() const dimMinMax = result?.byDimension @@ -58,12 +64,19 @@ export default chart => { ) : { min: Infinity, max: -Infinity } - if (dimMinMax.min === Infinity) return + if (dimMinMax.min === Infinity) { + if (typeof ymin === "undefined" || typeof ymax === "undefined") return + + convert(ymin, ymax) + + return + } convert(dimMinMax.min, dimMinMax.max) - }) + } - const offYAxisChange = chart.on("yAxisChange", convert) + const offVisibleDimensionsChanged = chart.on("visibleDimensionsChanged", () => onConvert()) + const offYAxisChange = chart.on("yAxisChange", onConvert) return () => { offYAxisChange()