???
This commit is contained in:
parent
01983f4e86
commit
9a5138b21d
17 changed files with 477 additions and 308 deletions
43
grid_line.go
Normal file
43
grid_line.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package chart
|
||||
|
||||
// GridLine is a line on a graph canvas.
|
||||
type GridLine struct {
|
||||
IsMinor bool
|
||||
IsVertical bool
|
||||
Style Style
|
||||
Value float64
|
||||
}
|
||||
|
||||
// Major returns if the gridline is a `major` line.
|
||||
func (gl GridLine) Major() bool {
|
||||
return !gl.IsMinor
|
||||
}
|
||||
|
||||
// Minor returns if the gridline is a `minor` line.
|
||||
func (gl GridLine) Minor() bool {
|
||||
return gl.IsMinor
|
||||
}
|
||||
|
||||
// Vertical returns if the line is vertical line or not.
|
||||
func (gl GridLine) Vertical() bool {
|
||||
return gl.IsVertical
|
||||
}
|
||||
|
||||
// Horizontal returns if the line is horizontal line or not.
|
||||
func (gl GridLine) Horizontal() bool {
|
||||
return !gl.IsVertical
|
||||
}
|
||||
|
||||
// Render renders the gridline
|
||||
func (gl GridLine) Render(r Renderer, canvasBox Box, ra Range) {
|
||||
lineleft := canvasBox.Left
|
||||
lineright := canvasBox.Right
|
||||
lineheight := canvasBox.Bottom - ra.Translate(gl.Value)
|
||||
|
||||
r.SetStrokeColor(gl.Style.GetStrokeColor(DefaultAxisColor))
|
||||
r.SetStrokeWidth(gl.Style.GetStrokeWidth(DefaultAxisLineWidth))
|
||||
|
||||
r.MoveTo(lineleft, lineheight)
|
||||
r.LineTo(lineright, lineheight)
|
||||
r.Stroke()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue