feat: support radar chart
This commit is contained in:
parent
6209a9ce63
commit
570828d35f
9 changed files with 337 additions and 35 deletions
21
pie_chart.go
21
pie_chart.go
|
|
@ -24,14 +24,11 @@ package charts
|
|||
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
)
|
||||
|
||||
const defaultRadiusPercent = 0.4
|
||||
|
||||
func getPieStyle(theme *Theme, index int) chart.Style {
|
||||
seriesColor := theme.GetSeriesColor(index)
|
||||
return chart.Style{
|
||||
|
|
@ -47,22 +44,6 @@ type pieChartOption struct {
|
|||
SeriesList SeriesList
|
||||
}
|
||||
|
||||
func getPieRadius(diameter float64, radiusValue string) float64 {
|
||||
var radius float64
|
||||
if len(radiusValue) != 0 {
|
||||
v := convertPercent(radiusValue)
|
||||
if v != -1 {
|
||||
radius = float64(diameter) * v
|
||||
} else {
|
||||
radius, _ = strconv.ParseFloat(radiusValue, 64)
|
||||
}
|
||||
}
|
||||
if radius <= 0 {
|
||||
radius = float64(diameter) * defaultRadiusPercent
|
||||
}
|
||||
return radius
|
||||
}
|
||||
|
||||
func pieChartRender(opt pieChartOption, result *basicRenderResult) error {
|
||||
d, err := NewDraw(DrawOption{
|
||||
Parent: result.d,
|
||||
|
|
@ -95,7 +76,7 @@ func pieChartRender(opt pieChartOption, result *basicRenderResult) error {
|
|||
cy := box.Height() >> 1
|
||||
|
||||
diameter := chart.MinInt(box.Width(), box.Height())
|
||||
radius := getPieRadius(float64(diameter), radiusValue)
|
||||
radius := getRadius(float64(diameter), radiusValue)
|
||||
|
||||
labelLineWidth := 15
|
||||
if radius < 50 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue