fix: fix NaN of radar chart, #17

This commit is contained in:
vicanso 2022-08-10 20:39:14 +08:00
parent 550b9874d2
commit 93e03856ca

View file

@ -200,7 +200,11 @@ func (r *radarChart) render(result *defaultRenderResult, seriesList SeriesList)
continue
}
indicator := indicators[j]
percent := (item.Value - indicator.Min) / (indicator.Max - indicator.Min)
var percent float64
offset := indicator.Max - indicator.Min
if offset > 0 {
percent = (item.Value - indicator.Min) / offset
}
r := percent * radius
p := getPolygonPoint(center, r, angles[j])
linePoints = append(linePoints, p)