style handling on gridlines.

This commit is contained in:
Will Charczuk 2016-07-24 20:27:19 -07:00
parent 2f7cd11039
commit 50a798f67f
3 changed files with 21 additions and 25 deletions

View file

@ -34,15 +34,16 @@ func (gl GridLine) Horizontal() bool {
}
// Render renders the gridline
func (gl GridLine) Render(r Renderer, canvasBox Box, ra Range) {
func (gl GridLine) Render(r Renderer, canvasBox Box, ra Range, defaults Style) {
r.SetStrokeColor(gl.Style.GetStrokeColor(defaults.GetStrokeColor()))
r.SetStrokeWidth(gl.Style.GetStrokeWidth(defaults.GetStrokeWidth()))
r.SetStrokeDashArray(gl.Style.GetStrokeDashArray(defaults.GetStrokeDashArray()))
if gl.IsVertical {
lineLeft := canvasBox.Left + ra.Translate(gl.Value)
lineBottom := canvasBox.Bottom
lineTop := canvasBox.Top
r.SetStrokeColor(gl.Style.GetStrokeColor(DefaultAxisColor))
r.SetStrokeWidth(gl.Style.GetStrokeWidth(DefaultAxisLineWidth))
r.MoveTo(lineLeft, lineBottom)
r.LineTo(lineLeft, lineTop)
r.Stroke()
@ -51,9 +52,6 @@ func (gl GridLine) Render(r Renderer, canvasBox Box, ra Range) {
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()
@ -61,17 +59,9 @@ func (gl GridLine) Render(r Renderer, canvasBox Box, ra Range) {
}
// GenerateGridLines generates grid lines.
func GenerateGridLines(ticks []Tick, isVertical bool) []GridLine {
func GenerateGridLines(ticks []Tick, majorStyle, minorStyle Style, isVertical bool) []GridLine {
var gl []GridLine
isMinor := false
minorStyle := Style{
StrokeColor: DefaultGridLineColor.WithAlpha(100),
StrokeWidth: 1.0,
}
majorStyle := Style{
StrokeColor: DefaultGridLineColor,
StrokeWidth: 1.0,
}
for _, t := range ticks {
s := majorStyle
if isMinor {