Skip to content

Commit

Permalink
Fix conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
novykh committed Jan 13, 2025
1 parent 8b4bf77 commit 86a4e79
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/helpers/unitConversion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 86a4e79

Please sign in to comment.