From e5cc7f9e9cfde743bfa365a1250905c8d5d590c8 Mon Sep 17 00:00:00 2001 From: Will Charczuk Date: Fri, 29 Jul 2016 19:40:41 -0700 Subject: [PATCH] looking spiffy. --- stacked_bar_chart.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stacked_bar_chart.go b/stacked_bar_chart.go index cbf093e..b719e0c 100644 --- a/stacked_bar_chart.go +++ b/stacked_bar_chart.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "math" "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() yoffset := canvasBox.Top for index, bv := range normalizedBarComponents { - barHeight := int(bv.Value * float64(canvasBox.Height())) - barBox := Box{Top: yoffset, Left: bxl, Right: bxr, Bottom: yoffset + barHeight} + barHeight := int(math.Ceil(bv.Value * float64(canvasBox.Height()))) + 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))) yoffset += barHeight }