Skip to content

Commit 86a4e79

Browse files
committed
Fix conversion.
1 parent 8b4bf77 commit 86a4e79

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/helpers/unitConversion/index.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ export default chart => {
4242
})
4343
}
4444

45-
const offVisibleDimensionsChanged = chart.on("visibleDimensionsChanged", () => {
45+
const onConvert = (ymin, ymax) => {
46+
if (Array.isArray(chart.getAttribute("staticValueRange"))) {
47+
const [min, max] = chart.getAttribute("staticValueRange")
48+
convert(min, max)
49+
return
50+
}
51+
4652
const result = chart.getPayload()
4753

4854
const dimMinMax = result?.byDimension
@@ -58,12 +64,19 @@ export default chart => {
5864
)
5965
: { min: Infinity, max: -Infinity }
6066

61-
if (dimMinMax.min === Infinity) return
67+
if (dimMinMax.min === Infinity) {
68+
if (typeof ymin === "undefined" || typeof ymax === "undefined") return
69+
70+
convert(ymin, ymax)
71+
72+
return
73+
}
6274

6375
convert(dimMinMax.min, dimMinMax.max)
64-
})
76+
}
6577

66-
const offYAxisChange = chart.on("yAxisChange", convert)
78+
const offVisibleDimensionsChanged = chart.on("visibleDimensionsChanged", () => onConvert())
79+
const offYAxisChange = chart.on("yAxisChange", onConvert)
6780

6881
return () => {
6982
offYAxisChange()

0 commit comments

Comments
 (0)