tweaks
This commit is contained in:
parent
1b0191ef78
commit
9cf709daf1
|
@ -1,7 +1,5 @@
|
||||||
package chart
|
package chart
|
||||||
|
|
||||||
import "math"
|
|
||||||
|
|
||||||
// DrawLineSeries draws a line series with a renderer.
|
// DrawLineSeries draws a line series with a renderer.
|
||||||
func DrawLineSeries(r Renderer, canvasBox Box, xrange, yrange Range, s Style, vs ValueProvider) {
|
func DrawLineSeries(r Renderer, canvasBox Box, xrange, yrange Range, s Style, vs ValueProvider) {
|
||||||
if vs.Len() == 0 {
|
if vs.Len() == 0 {
|
||||||
|
@ -53,8 +51,7 @@ func DrawLineSeries(r Renderer, canvasBox Box, xrange, yrange Range, s Style, vs
|
||||||
func MeasureAnnotation(r Renderer, canvasBox Box, xrange, yrange Range, s Style, lx, ly int, label string) Box {
|
func MeasureAnnotation(r Renderer, canvasBox Box, xrange, yrange Range, s Style, lx, ly int, label string) Box {
|
||||||
r.SetFont(s.GetFont())
|
r.SetFont(s.GetFont())
|
||||||
r.SetFontSize(s.GetFontSize(DefaultAnnotationFontSize))
|
r.SetFontSize(s.GetFontSize(DefaultAnnotationFontSize))
|
||||||
textWidth, _ := r.MeasureText(label)
|
textWidth, textHeight := r.MeasureText(label)
|
||||||
textHeight := int(math.Floor(DefaultAnnotationFontSize))
|
|
||||||
halfTextHeight := textHeight >> 1
|
halfTextHeight := textHeight >> 1
|
||||||
|
|
||||||
pt := s.Padding.GetTop(DefaultAnnotationPadding.Top)
|
pt := s.Padding.GetTop(DefaultAnnotationPadding.Top)
|
||||||
|
@ -62,17 +59,17 @@ func MeasureAnnotation(r Renderer, canvasBox Box, xrange, yrange Range, s Style,
|
||||||
pr := s.Padding.GetRight(DefaultAnnotationPadding.Right)
|
pr := s.Padding.GetRight(DefaultAnnotationPadding.Right)
|
||||||
pb := s.Padding.GetBottom(DefaultAnnotationPadding.Bottom)
|
pb := s.Padding.GetBottom(DefaultAnnotationPadding.Bottom)
|
||||||
|
|
||||||
ltly := ly - (pt + halfTextHeight)
|
top := ly - (pt + halfTextHeight)
|
||||||
ltrx := lx + pl + pr + textWidth
|
right := lx + pl + pr + textWidth
|
||||||
lbry := ly + (pb + halfTextHeight)
|
bottom := ly + (pb + halfTextHeight)
|
||||||
|
|
||||||
return Box{
|
return Box{
|
||||||
Top: ltly,
|
Top: top,
|
||||||
Left: lx,
|
Left: lx,
|
||||||
Right: ltrx,
|
Right: right,
|
||||||
Bottom: lbry,
|
Bottom: bottom,
|
||||||
Width: ltrx - lx,
|
Width: right - lx,
|
||||||
Height: lbry - ltly,
|
Height: bottom - top,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,17 +88,17 @@ func DrawAnnotation(r Renderer, canvasBox Box, xrange, yrange Range, s Style, lx
|
||||||
textX := lx + pl + DefaultAnnotationDeltaWidth
|
textX := lx + pl + DefaultAnnotationDeltaWidth
|
||||||
textY := ly + halfTextHeight
|
textY := ly + halfTextHeight
|
||||||
|
|
||||||
ltlx := lx + pl + DefaultAnnotationDeltaWidth
|
ltx := lx + pl + DefaultAnnotationDeltaWidth
|
||||||
ltly := ly - (pt + halfTextHeight)
|
lty := ly - (pt + halfTextHeight)
|
||||||
|
|
||||||
ltrx := lx + pl + pr + textWidth
|
rtx := lx + pl + pr + textWidth
|
||||||
ltry := ly - (pt + halfTextHeight)
|
rty := ly - (pt + halfTextHeight)
|
||||||
|
|
||||||
lbrx := lx + pl + pr + textWidth
|
rbx := lx + pl + pr + textWidth
|
||||||
lbry := ly + (pb + halfTextHeight)
|
rby := ly + (pb + halfTextHeight)
|
||||||
|
|
||||||
lblx := lx + DefaultAnnotationDeltaWidth
|
lbx := lx + DefaultAnnotationDeltaWidth
|
||||||
lbly := ly + (pb + halfTextHeight)
|
lby := ly + (pb + halfTextHeight)
|
||||||
|
|
||||||
//draw the shape...
|
//draw the shape...
|
||||||
r.SetFillColor(s.GetFillColor(DefaultAnnotationFillColor))
|
r.SetFillColor(s.GetFillColor(DefaultAnnotationFillColor))
|
||||||
|
@ -109,10 +106,10 @@ func DrawAnnotation(r Renderer, canvasBox Box, xrange, yrange Range, s Style, lx
|
||||||
r.SetStrokeWidth(s.GetStrokeWidth())
|
r.SetStrokeWidth(s.GetStrokeWidth())
|
||||||
|
|
||||||
r.MoveTo(lx, ly)
|
r.MoveTo(lx, ly)
|
||||||
r.LineTo(ltlx, ltly)
|
r.LineTo(ltx, lty)
|
||||||
r.LineTo(ltrx, ltry)
|
r.LineTo(rtx, rty)
|
||||||
r.LineTo(lbrx, lbry)
|
r.LineTo(rbx, rby)
|
||||||
r.LineTo(lblx, lbly)
|
r.LineTo(lbx, lby)
|
||||||
r.LineTo(lx, ly)
|
r.LineTo(lx, ly)
|
||||||
r.Close()
|
r.Close()
|
||||||
r.FillStroke()
|
r.FillStroke()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user