refactor: adjust max value of axis, #19

This commit is contained in:
vicanso 2022-08-28 09:43:18 +08:00
parent dc1a89d3ff
commit 128d5b2774
2 changed files with 9 additions and 2 deletions

View file

@ -60,7 +60,10 @@ func NewRange(opt AxisRangeOption) axisRange {
r := math.Abs(max - min)
// 最小单位计算
unit := 2
unit := 1
if r > 5 {
unit = 2
}
if r > 10 {
unit = 4
}
@ -85,6 +88,10 @@ func NewRange(opt AxisRangeOption) axisRange {
}
}
max = min + float64(unit*divideCount)
expectMax := opt.Max * 2
if max > expectMax {
max = float64(ceilFloatToInt(expectMax))
}
return axisRange{
divideCount: divideCount,
min: min,