tweaks.
This commit is contained in:
parent
c173dcadd3
commit
29ffceeec0
2 changed files with 7 additions and 8 deletions
11
chart.go
11
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 {
|
func (c Chart) getXAxisHeight(r Renderer, ticks []Tick) int {
|
||||||
r.SetFontSize(c.XAxis.Style.GetFontSize(DefaultFontSize))
|
r.SetFontSize(c.XAxis.Style.GetFontSize(DefaultFontSize))
|
||||||
r.SetFont(c.XAxis.Style.GetFont(c.Font))
|
r.SetFont(c.XAxis.Style.GetFont(c.Font))
|
||||||
var tl int
|
|
||||||
|
var textHeight int
|
||||||
for _, t := range ticks {
|
for _, t := range ticks {
|
||||||
_, lh := r.MeasureText(t.Label)
|
_, th := r.MeasureText(t.Label)
|
||||||
if lh > tl {
|
if th > textHeight {
|
||||||
tl = lh
|
textHeight = th
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tl + DefaultXAxisMargin
|
return textHeight + (2 * DefaultXAxisMargin) // top and bottom.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Chart) getYAxisWidth(r Renderer, ticks []Tick) int {
|
func (c Chart) getYAxisWidth(r Renderer, ticks []Tick) int {
|
||||||
|
|
4
xaxis.go
4
xaxis.go
|
@ -80,16 +80,14 @@ func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, ticks []Tick) {
|
||||||
|
|
||||||
sort.Sort(Ticks(ticks))
|
sort.Sort(Ticks(ticks))
|
||||||
|
|
||||||
textHeight := 0
|
var textHeight int
|
||||||
for _, t := range ticks {
|
for _, t := range ticks {
|
||||||
_, th := r.MeasureText(t.Label)
|
_, th := r.MeasureText(t.Label)
|
||||||
if th > textHeight {
|
if th > textHeight {
|
||||||
textHeight = th
|
textHeight = th
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty := canvasBox.Bottom + DefaultXAxisMargin + int(textHeight)
|
ty := canvasBox.Bottom + DefaultXAxisMargin + int(textHeight)
|
||||||
|
|
||||||
for _, t := range ticks {
|
for _, t := range ticks {
|
||||||
v := t.Value
|
v := t.Value
|
||||||
x := ra.Translate(v)
|
x := ra.Translate(v)
|
||||||
|
|
Loading…
Reference in a new issue