feat: support bar margin
This commit is contained in:
parent
32e6dd52d0
commit
e7dc4189d5
4 changed files with 20 additions and 4 deletions
|
|
@ -50,6 +50,8 @@ type HorizontalBarChartOption struct {
|
|||
// The legend option
|
||||
Legend LegendOption
|
||||
BarHeight int
|
||||
// Margin of bar
|
||||
BarMargin int
|
||||
}
|
||||
|
||||
// NewHorizontalBarChart returns a horizontal bar chart renderer
|
||||
|
|
@ -81,6 +83,9 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
|
|||
margin = 5
|
||||
barMargin = 3
|
||||
}
|
||||
if opt.BarMargin > 0 {
|
||||
barMargin = opt.BarMargin
|
||||
}
|
||||
seriesCount := len(seriesList)
|
||||
// 总的高度-两个margin-(总数-1)的barMargin
|
||||
barHeight := (height - 2*margin - barMargin*(seriesCount-1)) / seriesCount
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue