refactor: return error if sum value of pie is not gt 0

This commit is contained in:
vicanso 2022-03-07 21:00:32 +08:00
parent 981e5a0d27
commit 1be8d43405
2 changed files with 7 additions and 1 deletions

View file

@ -23,6 +23,7 @@
package charts
import (
"errors"
"math"
"github.com/golang/freetype/truetype"
@ -68,6 +69,9 @@ func pieChartRender(opt pieChartOption, result *basicRenderResult) error {
values[index] = value
total += value
}
if total <= 0 {
return errors.New("The sum value of pie chart should gt 0")
}
r := d.Render
theme := NewTheme(opt.Theme)