things
This commit is contained in:
parent
cb5c2df263
commit
c173dcadd3
2 changed files with 16 additions and 5 deletions
|
@ -112,13 +112,15 @@ func measureTestHandler(rc *web.RequestContext) web.ControllerResult {
|
||||||
}
|
}
|
||||||
r.SetDPI(96)
|
r.SetDPI(96)
|
||||||
r.SetFont(f)
|
r.SetFont(f)
|
||||||
r.SetFontSize(24.0)
|
r.SetFontSize(10.0)
|
||||||
r.SetFontColor(drawing.ColorBlack)
|
r.SetFontColor(drawing.ColorBlack)
|
||||||
r.SetStrokeColor(drawing.ColorBlack)
|
r.SetStrokeColor(drawing.ColorBlack)
|
||||||
|
|
||||||
|
label := "goog - 702.23"
|
||||||
|
|
||||||
tx, ty := 64, 64
|
tx, ty := 64, 64
|
||||||
|
|
||||||
tw, th := r.MeasureText("test")
|
tw, th := r.MeasureText(label)
|
||||||
r.MoveTo(tx, ty)
|
r.MoveTo(tx, ty)
|
||||||
r.LineTo(tx+tw, ty)
|
r.LineTo(tx+tw, ty)
|
||||||
r.LineTo(tx+tw, ty-th)
|
r.LineTo(tx+tw, ty-th)
|
||||||
|
@ -126,7 +128,7 @@ func measureTestHandler(rc *web.RequestContext) web.ControllerResult {
|
||||||
r.LineTo(tx, ty)
|
r.LineTo(tx, ty)
|
||||||
r.Stroke()
|
r.Stroke()
|
||||||
|
|
||||||
r.Text("test", tx, ty)
|
r.Text(label, tx, ty)
|
||||||
|
|
||||||
r.Save(rc.Response)
|
r.Save(rc.Response)
|
||||||
return nil
|
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
|
// Render renders the axis
|
||||||
func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, ticks []Tick) {
|
func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, ticks []Tick) {
|
||||||
tickFontSize := xa.Style.GetFontSize(DefaultFontSize)
|
tickFontSize := xa.Style.GetFontSize(DefaultFontSize)
|
||||||
tickHeight := drawing.PointsToPixels(r.GetDPI(), tickFontSize)
|
|
||||||
ty := canvasBox.Bottom + DefaultXAxisMargin + int(tickHeight)
|
|
||||||
|
|
||||||
r.SetStrokeColor(xa.Style.GetStrokeColor(DefaultAxisColor))
|
r.SetStrokeColor(xa.Style.GetStrokeColor(DefaultAxisColor))
|
||||||
r.SetStrokeWidth(xa.Style.GetStrokeWidth(DefaultAxisLineWidth))
|
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)
|
r.SetFontSize(tickFontSize)
|
||||||
|
|
||||||
sort.Sort(Ticks(ticks))
|
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 {
|
for _, t := range ticks {
|
||||||
v := t.Value
|
v := t.Value
|
||||||
x := ra.Translate(v)
|
x := ra.Translate(v)
|
||||||
|
|
Loading…
Reference in a new issue