From 1269397821ad4a7cd81df957ead800c93f076de5 Mon Sep 17 00:00:00 2001 From: Will Charczuk Date: Fri, 29 Jul 2016 19:38:37 -0700 Subject: [PATCH] sbc looking alright, need to debug bar gaps at the bottom --- examples/stacked_bar/main.go | 4 ++-- stacked_bar_chart.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/stacked_bar/main.go b/examples/stacked_bar/main.go index 5096f61..ddc3700 100644 --- a/examples/stacked_bar/main.go +++ b/examples/stacked_bar/main.go @@ -26,9 +26,9 @@ func drawChart(res http.ResponseWriter, req *http.Request) { {Value: 5, Label: "Blue"}, {Value: 5, Label: "Green"}, {Value: 4, Label: "Gray"}, - {Value: 4, Label: "Orange"}, + {Value: 3, Label: "Orange"}, {Value: 3, Label: "Test"}, - {Value: 3, Label: "??"}, + {Value: 2, Label: "??"}, {Value: 1, Label: "!!"}, }, }, diff --git a/stacked_bar_chart.go b/stacked_bar_chart.go index 1fe22e2..cbf093e 100644 --- a/stacked_bar_chart.go +++ b/stacked_bar_chart.go @@ -197,13 +197,17 @@ func (sbc StackedBarChart) drawYAxis(r Renderer, canvasBox Box) { ticks := Sequence.Float64(1.0, 0.0, 0.2) for _, t := range ticks { + axisStyle.GetStrokeOptions().WriteToRenderer(r) ty := canvasBox.Bottom - int(t*float64(canvasBox.Height())) r.MoveTo(canvasBox.Right, ty) r.LineTo(canvasBox.Right+DefaultHorizontalTickWidth, ty) r.Stroke() + axisStyle.GetTextOptions().WriteToRenderer(r) text := fmt.Sprintf("%0.0f%%", t*100) - Draw.Text(r, text, canvasBox.Right+DefaultYAxisMargin, ty, axisStyle) + + tb := r.MeasureText(text) + Draw.Text(r, text, canvasBox.Right+DefaultYAxisMargin+5, ty+(tb.Height()>>1), axisStyle) } }