tweaks
This commit is contained in:
parent
5b590c23d4
commit
1b0191ef78
2 changed files with 13 additions and 13 deletions
15
chart.go
15
chart.go
|
@ -288,17 +288,18 @@ func (c Chart) getYAxisWidth(r Renderer, ticks []Tick) int {
|
|||
}
|
||||
|
||||
func (c Chart) getYAxisSecondaryWidth(r Renderer, ticks []Tick) int {
|
||||
var ll string
|
||||
r.SetFontSize(c.YAxisSecondary.Style.GetFontSize(DefaultFontSize))
|
||||
r.SetFont(c.YAxisSecondary.Style.GetFont(c.Font))
|
||||
|
||||
var textWidth int
|
||||
for _, t := range ticks {
|
||||
if len(t.Label) > len(ll) {
|
||||
ll = t.Label
|
||||
tw, _ := r.MeasureText(t.Label)
|
||||
if tw > textWidth {
|
||||
textWidth = tw
|
||||
}
|
||||
}
|
||||
|
||||
r.SetFontSize(c.YAxisSecondary.Style.GetFontSize(DefaultFontSize))
|
||||
r.SetFont(c.YAxisSecondary.Style.GetFont(c.Font))
|
||||
tw, _ := r.MeasureText(ll)
|
||||
return tw + DefaultYAxisMargin
|
||||
return textWidth + DefaultYAxisMargin
|
||||
}
|
||||
|
||||
func (c Chart) setRangeDomains(canvasBox Box, xrange, yrange, yrangeAlt Range) (Range, Range, Range) {
|
||||
|
|
11
yaxis.go
11
yaxis.go
|
@ -77,8 +77,8 @@ func (ya YAxis) Render(r Renderer, canvasBox Box, ra Range, axisType YAxisType,
|
|||
v := t.Value
|
||||
ly := ra.Translate(v) + canvasBox.Top
|
||||
|
||||
th := int(fontSize) >> 1
|
||||
ty := ly + th
|
||||
_, pth := r.MeasureText(t.Label)
|
||||
ty := ly + pth>>1
|
||||
|
||||
r.Text(t.Label, tx, ty)
|
||||
|
||||
|
@ -97,13 +97,12 @@ func (ya YAxis) Render(r Renderer, canvasBox Box, ra Range, axisType YAxisType,
|
|||
v := t.Value
|
||||
ly := ra.Translate(v) + canvasBox.Top
|
||||
|
||||
ptw, _ := r.MeasureText(t.Label)
|
||||
ptw, pth := r.MeasureText(t.Label)
|
||||
|
||||
tw := ptw
|
||||
th := int(fontSize)
|
||||
|
||||
tx = lx - (int(tw) + (DefaultYAxisMargin >> 1))
|
||||
ty := ly + th>>1
|
||||
tx = lx - (tw + DefaultYAxisMargin)
|
||||
ty := ly + pth>>1
|
||||
|
||||
r.Text(t.Label, tx, ty)
|
||||
|
||||
|
|
Loading…
Reference in a new issue