things
This commit is contained in:
parent
cb5c2df263
commit
c173dcadd3
|
@ -112,13 +112,15 @@ func measureTestHandler(rc *web.RequestContext) web.ControllerResult {
|
|||
}
|
||||
r.SetDPI(96)
|
||||
r.SetFont(f)
|
||||
r.SetFontSize(24.0)
|
||||
r.SetFontSize(10.0)
|
||||
r.SetFontColor(drawing.ColorBlack)
|
||||
r.SetStrokeColor(drawing.ColorBlack)
|
||||
|
||||
label := "goog - 702.23"
|
||||
|
||||
tx, ty := 64, 64
|
||||
|
||||
tw, th := r.MeasureText("test")
|
||||
tw, th := r.MeasureText(label)
|
||||
r.MoveTo(tx, ty)
|
||||
r.LineTo(tx+tw, ty)
|
||||
r.LineTo(tx+tw, ty-th)
|
||||
|
@ -126,7 +128,7 @@ func measureTestHandler(rc *web.RequestContext) web.ControllerResult {
|
|||
r.LineTo(tx, ty)
|
||||
r.Stroke()
|
||||
|
||||
r.Text("test", tx, ty)
|
||||
r.Text(label, tx, ty)
|
||||
|
||||
r.Save(rc.Response)
|
||||
return nil
|
||||
|
|
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…
Reference in New Issue
Block a user