Skip to content

Commit

Permalink
fix: fix indicator minValue and maxValue invalid error.
Browse files Browse the repository at this point in the history
  • Loading branch information
liihuu committed Jan 10, 2024
1 parent bbad15d commit f39d387
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/component/YAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export default class YAxisImp extends AxisImp implements YAxis {
shouldOhlc = indicator.shouldOhlc ?? false
}
indicatorPrecision = Math.min(indicatorPrecision, indicator.precision)
if (indicator.minValue !== null) {
if (isNumber(indicator.minValue)) {
specifyMin = Math.min(specifyMin, indicator.minValue)
}
if (indicator.maxValue !== null) {
if (isNumber(indicator.maxValue)) {
specifyMax = Math.max(specifyMax, indicator.maxValue)
}
figuresResultList.push({
Expand Down Expand Up @@ -105,6 +105,7 @@ export default class YAxisImp extends AxisImp implements YAxis {
})
})
})

if (min !== Number.MAX_SAFE_INTEGER && max !== Number.MIN_SAFE_INTEGER) {
min = Math.min(specifyMin, min)
max = Math.max(specifyMax, max)
Expand Down Expand Up @@ -156,7 +157,7 @@ export default class YAxisImp extends AxisImp implements YAxis {
bottomRate = bottomRate / height
}
let range = Math.abs(max - min)
// 保证每次图形绘制上下都留间隙
// gap
min = min - range * bottomRate
max = max + range * topRate
range = Math.abs(max - min)
Expand All @@ -172,6 +173,7 @@ export default class YAxisImp extends AxisImp implements YAxis {
realMax = max
realRange = range
}

return {
min, max, range, realMin, realMax, realRange
}
Expand Down
4 changes: 2 additions & 2 deletions src/store/IndicatorStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export default class IndicatorStore {
updateFlag = true
calcFlag = true
}
if (instance.setMinValue(minValue ?? null)) {
if (minValue !== undefined && instance.setMinValue(minValue)) {
updateFlag = true
}
if (instance.setMinValue(maxValue ?? null)) {
if (maxValue !== undefined && instance.setMinValue(maxValue)) {
updateFlag = true
}
if (isNumber(precision) && instance.setPrecision(precision)) {
Expand Down

0 comments on commit f39d387

Please sign in to comment.