From fc2973067ce43455507ea5f9aa9814aabbf8f2ca Mon Sep 17 00:00:00 2001 From: Will Charczuk Date: Thu, 27 Oct 2016 10:40:27 -0700 Subject: [PATCH] fixing y-axis label position --- yaxis.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/yaxis.go b/yaxis.go index 0695276..da3a559 100644 --- a/yaxis.go +++ b/yaxis.go @@ -195,7 +195,12 @@ func (ya YAxis) Render(r Renderer, canvasBox Box, ra Range, defaults Style, tick tx = canvasBox.Left - (DefaultYAxisMargin + int(sw) + maxTextWidth + DefaultYAxisMargin) } - ty := canvasBox.Top + (canvasBox.Height()>>1 + tb.Width()>>1) + var ty int + if nameStyle.TextRotationDegrees == 0 { + ty = canvasBox.Top + (canvasBox.Height()>>1 - tb.Width()>>1) + } else { + ty = canvasBox.Top + (canvasBox.Height()>>1 - tb.Height()>>1) + } Draw.Text(r, ya.Name, tx, ty, nameStyle) }