fixing y-axis label position

This commit is contained in:
Will Charczuk 2016-10-27 10:40:27 -07:00
parent e8de11d590
commit fc2973067c

View File

@ -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) 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) Draw.Text(r, ya.Name, tx, ty, nameStyle)
} }