things
This commit is contained in:
parent
cb5c2df263
commit
c173dcadd3
2 changed files with 16 additions and 5 deletions
13
xaxis.go
13
xaxis.go
|
|
@ -67,8 +67,6 @@ func (xa XAxis) getTickCount(r Renderer, ra Range, vf ValueFormatter) int {
|
|||
// Render renders the axis
|
||||
func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, ticks []Tick) {
|
||||
tickFontSize := xa.Style.GetFontSize(DefaultFontSize)
|
||||
tickHeight := drawing.PointsToPixels(r.GetDPI(), tickFontSize)
|
||||
ty := canvasBox.Bottom + DefaultXAxisMargin + int(tickHeight)
|
||||
|
||||
r.SetStrokeColor(xa.Style.GetStrokeColor(DefaultAxisColor))
|
||||
r.SetStrokeWidth(xa.Style.GetStrokeWidth(DefaultAxisLineWidth))
|
||||
|
|
@ -81,6 +79,17 @@ func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, ticks []Tick) {
|
|||
r.SetFontSize(tickFontSize)
|
||||
|
||||
sort.Sort(Ticks(ticks))
|
||||
|
||||
textHeight := 0
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue