Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
fixing undertick
Browse files Browse the repository at this point in the history
  • Loading branch information
wcharczuk committed Jul 30, 2016
1 parent bf962d2 commit 457fefb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions xaxis.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,22 @@ func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, defaults Style, tick
for index, t := range ticks {
v := t.Value
lx := ra.Translate(v)
tb := r.MeasureText(t.Label)

tx = canvasBox.Left + lx
ty = canvasBox.Bottom + DefaultXAxisMargin + tb.Height()

tickStyle.GetStrokeOptions().WriteToRenderer(r)
r.MoveTo(tx, canvasBox.Bottom)
r.LineTo(tx, canvasBox.Bottom+DefaultVerticalTickHeight)
r.Stroke()

tickStyle.GetTextOptions().WriteToRenderer(r)
tb := r.MeasureText(t.Label)

switch tp {
case TickPositionUnderTick:
tickStyle.GetTextOptions().WriteToRenderer(r)
case TickPositionUnderTick, TickPositionUnset:
ty = canvasBox.Bottom + DefaultXAxisMargin + tb.Height()
r.Text(t.Label, tx-tb.Width()>>1, ty)
break
case TickPositionBetweenTicks:
if index > 0 {
llx := ra.Translate(ticks[index-1].Value)
Expand All @@ -135,6 +137,7 @@ func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, defaults Style, tick
Bottom: canvasBox.Bottom + DefaultXAxisMargin + tb.Height(),
}, tickStyle.InheritFrom(Style{TextHorizontalAlign: TextHorizontalAlignCenter}))
}
break
}

}
Expand Down

0 comments on commit 457fefb

Please sign in to comment.