refactor: return error if sum value of pie is not gt 0
This commit is contained in:
parent
981e5a0d27
commit
1be8d43405
2 changed files with 7 additions and 1 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue