feat: support rounded rect for horizontal bar chart
This commit is contained in:
parent
9b7634c2c2
commit
9614835723
2 changed files with 23 additions and 8 deletions
|
|
@ -65,6 +65,9 @@ func main() {
|
||||||
"China",
|
"China",
|
||||||
"World",
|
"World",
|
||||||
}),
|
}),
|
||||||
|
func(opt *charts.ChartOption) {
|
||||||
|
opt.SeriesList[0].RoundRadius = 5
|
||||||
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
|
||||||
fillColor = item.Style.FillColor
|
fillColor = item.Style.FillColor
|
||||||
}
|
}
|
||||||
right := w
|
right := w
|
||||||
|
if series.RoundRadius <= 0 {
|
||||||
seriesPainter.OverrideDrawingStyle(Style{
|
seriesPainter.OverrideDrawingStyle(Style{
|
||||||
FillColor: fillColor,
|
FillColor: fillColor,
|
||||||
}).Rect(chart.Box{
|
}).Rect(chart.Box{
|
||||||
|
|
@ -144,6 +145,17 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
|
||||||
Right: right,
|
Right: right,
|
||||||
Bottom: y + barHeight,
|
Bottom: y + barHeight,
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
seriesPainter.OverrideDrawingStyle(Style{
|
||||||
|
FillColor: fillColor,
|
||||||
|
}).RoundedRect(chart.Box{
|
||||||
|
Top: y,
|
||||||
|
Left: 0,
|
||||||
|
Right: right,
|
||||||
|
Bottom: y + barHeight,
|
||||||
|
}, series.RoundRadius)
|
||||||
|
}
|
||||||
|
|
||||||
// 如果label不需要展示,则返回
|
// 如果label不需要展示,则返回
|
||||||
if labelPainter == nil {
|
if labelPainter == nil {
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue