looking spiffy.

This commit is contained in:
Will Charczuk 2016-07-29 19:40:41 -07:00
parent 1269397821
commit e5cc7f9e9c

View File

@ -4,6 +4,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"math"
"github.com/golang/freetype/truetype" "github.com/golang/freetype/truetype"
) )
@ -138,8 +139,8 @@ func (sbc StackedBarChart) drawBar(r Renderer, canvasBox Box, xoffset int, bar S
normalizedBarComponents := Values(bar.Values).Normalize() normalizedBarComponents := Values(bar.Values).Normalize()
yoffset := canvasBox.Top yoffset := canvasBox.Top
for index, bv := range normalizedBarComponents { for index, bv := range normalizedBarComponents {
barHeight := int(bv.Value * float64(canvasBox.Height())) barHeight := int(math.Ceil(bv.Value * float64(canvasBox.Height())))
barBox := Box{Top: yoffset, Left: bxl, Right: bxr, Bottom: yoffset + barHeight} barBox := Box{Top: yoffset, Left: bxl, Right: bxr, Bottom: Math.MinInt(yoffset+barHeight, canvasBox.Bottom-DefaultStrokeWidth)}
Draw.Box(r, barBox, bv.Style.InheritFrom(sbc.styleDefaultsStackedBarValue(index))) Draw.Box(r, barBox, bv.Style.InheritFrom(sbc.styleDefaultsStackedBarValue(index)))
yoffset += barHeight yoffset += barHeight
} }