From 4a1ff8055656382652b49cafc7ee22132884ebcc Mon Sep 17 00:00:00 2001 From: vicanso Date: Thu, 1 Sep 2022 20:20:51 +0800 Subject: [PATCH] fix: fix min and max option of y axis --- .github/workflows/test.yml | 1 + charts.go | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 22e77a8..61449a3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,7 @@ jobs: strategy: matrix: go: + - '1.19' - '1.18' - '1.17' - '1.16' diff --git a/charts.go b/charts.go index 849f0c7..6d5dc56 100644 --- a/charts.go +++ b/charts.go @@ -174,12 +174,6 @@ func defaultRender(p *Painter, opt defaultRenderOption) (*defaultRenderResult, e yAxisOption = opt.YAxisOptions[index] } max, min := opt.SeriesList.GetMaxMin(index) - if yAxisOption.Min != nil { - min = *yAxisOption.Min - } - if yAxisOption.Max != nil { - max = *yAxisOption.Max - } r := NewRange(AxisRangeOption{ Min: min, Max: max, @@ -188,6 +182,12 @@ func defaultRender(p *Painter, opt defaultRenderOption) (*defaultRenderResult, e // 分隔数量 DivideCount: defaultAxisDivideCount, }) + if yAxisOption.Min != nil && *yAxisOption.Min <= min { + r.min = *yAxisOption.Min + } + if yAxisOption.Max != nil && *yAxisOption.Max >= max { + r.max = *yAxisOption.Max + } result.axisRanges[index] = r if yAxisOption.Theme == nil {