fix: fix overflow point

This commit is contained in:
vicanso 2022-02-19 17:44:46 +08:00
parent bbbdbe7c5e
commit 28bb9c57bc
3 changed files with 10 additions and 4 deletions

View file

@ -98,7 +98,7 @@ func barChartRender(opt barChartOption, result *basicRenderResult) ([]markPointR
})
divideValues := xRange.AutoDivide()
for j, item := range series.Data {
if j >= len(divideValues) {
if j >= xRange.divideCount {
continue
}
x := divideValues[j]

View file

@ -423,6 +423,7 @@ func indexHandler(w http.ResponseWriter, req *http.Request) {
20.0,
6.4,
3.3,
10.2,
}),
YAxisIndex: 1,
},
@ -441,6 +442,7 @@ func indexHandler(w http.ResponseWriter, req *http.Request) {
18.8,
6.0,
2.3,
20.2,
}),
YAxisIndex: 1,
},
@ -458,6 +460,7 @@ func indexHandler(w http.ResponseWriter, req *http.Request) {
16.5,
12.0,
6.2,
30.3,
}),
},
},

View file

@ -63,7 +63,7 @@ func lineChartRender(opt lineChartOption, result *basicRenderResult) ([]markPoin
seriesColor := theme.GetSeriesColor(index)
yRange := result.getYRange(series.YAxisIndex)
points := make([]Point, len(series.Data))
points := make([]Point, 0, len(series.Data))
// mark line
markLineRender(markLineRenderOption{
Draw: d,
@ -76,12 +76,15 @@ func lineChartRender(opt lineChartOption, result *basicRenderResult) ([]markPoin
})
for j, item := range series.Data {
if j >= xRange.divideCount {
continue
}
y := yRange.getRestHeight(item.Value)
x := xRange.getWidth(float64(j))
points[j] = Point{
points = append(points, Point{
Y: y,
X: x,
}
})
if !series.Label.Show {
continue
}