Added BaseValue funtionality to bar chart (#94)
This commit is contained in:
parent
d667b8c983
commit
3edccc4758
3 changed files with 105 additions and 5 deletions
22
bar_chart.go
22
bar_chart.go
|
|
@ -31,6 +31,9 @@ type BarChart struct {
|
|||
|
||||
BarSpacing int
|
||||
|
||||
UseBaseValue bool
|
||||
BaseValue float64
|
||||
|
||||
Font *truetype.Font
|
||||
defaultFont *truetype.Font
|
||||
|
||||
|
|
@ -199,11 +202,20 @@ func (bc BarChart) drawBars(r Renderer, canvasBox Box, yr Range) {
|
|||
|
||||
by = canvasBox.Bottom - yr.Translate(bar.Value)
|
||||
|
||||
barBox = Box{
|
||||
Top: by,
|
||||
Left: bxl,
|
||||
Right: bxr,
|
||||
Bottom: canvasBox.Bottom,
|
||||
if bc.UseBaseValue {
|
||||
barBox = Box{
|
||||
Top: by,
|
||||
Left: bxl,
|
||||
Right: bxr,
|
||||
Bottom: canvasBox.Bottom - yr.Translate(bc.BaseValue),
|
||||
}
|
||||
} else {
|
||||
barBox = Box{
|
||||
Top: by,
|
||||
Left: bxl,
|
||||
Right: bxr,
|
||||
Bottom: canvasBox.Bottom,
|
||||
}
|
||||
}
|
||||
|
||||
Draw.Box(r, barBox, bar.Style.InheritFrom(bc.styleDefaultsBar(index)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue