test: add test for chart
This commit is contained in:
parent
56709e22b7
commit
11fdd9121a
4 changed files with 304 additions and 16 deletions
29
pie_chart.go
29
pie_chart.go
|
|
@ -47,6 +47,22 @@ 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,
|
||||
|
|
@ -79,19 +95,8 @@ func pieChartRender(opt pieChartOption, result *basicRenderResult) error {
|
|||
cy := box.Height() >> 1
|
||||
|
||||
diameter := chart.MinInt(box.Width(), box.Height())
|
||||
radius := getPieRadius(float64(diameter), radiusValue)
|
||||
|
||||
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
|
||||
}
|
||||
labelLineWidth := 15
|
||||
if radius < 50 {
|
||||
labelLineWidth = 10
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue