From 5b590c23d47bec1f5b04832fc7dcb3ed9df07439 Mon Sep 17 00:00:00 2001 From: Will Charczuk Date: Mon, 11 Jul 2016 00:08:14 -0700 Subject: [PATCH] tweaks --- chart.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/chart.go b/chart.go index 4068c67..2ddbd8a 100644 --- a/chart.go +++ b/chart.go @@ -273,16 +273,18 @@ func (c Chart) getXAxisHeight(r Renderer, ticks []Tick) int { } func (c Chart) getYAxisWidth(r Renderer, ticks []Tick) int { - var ll string - for _, t := range ticks { - if len(t.Label) > len(ll) { - ll = t.Label - } - } r.SetFontSize(c.YAxis.Style.GetFontSize(DefaultFontSize)) r.SetFont(c.YAxis.Style.GetFont(c.Font)) - tw, _ := r.MeasureText(ll) - return tw + DefaultYAxisMargin + + var textWidth int + for _, t := range ticks { + tw, _ := r.MeasureText(t.Label) + if tw > textWidth { + textWidth = tw + } + } + + return textWidth + DefaultYAxisMargin } func (c Chart) getYAxisSecondaryWidth(r Renderer, ticks []Tick) int {