From 29ffceeec0d9369c9d392720dea06fcd128d899b Mon Sep 17 00:00:00 2001 From: Will Charczuk Date: Mon, 11 Jul 2016 00:05:48 -0700 Subject: [PATCH] tweaks. --- chart.go | 11 ++++++----- xaxis.go | 4 +--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/chart.go b/chart.go index afefa06..4068c67 100644 --- a/chart.go +++ b/chart.go @@ -261,14 +261,15 @@ func (c Chart) getAxisAdjustedCanvasBox(r Renderer, defaults Box, xticks, yticks func (c Chart) getXAxisHeight(r Renderer, ticks []Tick) int { r.SetFontSize(c.XAxis.Style.GetFontSize(DefaultFontSize)) r.SetFont(c.XAxis.Style.GetFont(c.Font)) - var tl int + + var textHeight int for _, t := range ticks { - _, lh := r.MeasureText(t.Label) - if lh > tl { - tl = lh + _, th := r.MeasureText(t.Label) + if th > textHeight { + textHeight = th } } - return tl + DefaultXAxisMargin + return textHeight + (2 * DefaultXAxisMargin) // top and bottom. } func (c Chart) getYAxisWidth(r Renderer, ticks []Tick) int { diff --git a/xaxis.go b/xaxis.go index 035c056..09fd350 100644 --- a/xaxis.go +++ b/xaxis.go @@ -80,16 +80,14 @@ func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, ticks []Tick) { sort.Sort(Ticks(ticks)) - textHeight := 0 + var textHeight int for _, t := range ticks { _, th := r.MeasureText(t.Label) if th > textHeight { textHeight = th } } - ty := canvasBox.Bottom + DefaultXAxisMargin + int(textHeight) - for _, t := range ticks { v := t.Value x := ra.Translate(v)