inching up coverage.
This commit is contained in:
parent
bacb0023b5
commit
c30e677f16
7 changed files with 236 additions and 112 deletions
53
xaxis.go
53
xaxis.go
|
|
@ -71,41 +71,16 @@ func (xa XAxis) GetGridLines(ticks []Tick) []GridLine {
|
|||
if len(xa.GridLines) > 0 {
|
||||
return xa.GridLines
|
||||
}
|
||||
return xa.generateGridLines(ticks)
|
||||
}
|
||||
|
||||
func (xa XAxis) generateGridLines(ticks []Tick) []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 {
|
||||
s = minorStyle
|
||||
}
|
||||
gl = append(gl, GridLine{
|
||||
Style: s,
|
||||
IsMinor: isMinor,
|
||||
IsVertical: true,
|
||||
Value: t.Value,
|
||||
})
|
||||
isMinor = !isMinor
|
||||
}
|
||||
return gl
|
||||
return GenerateGridLines(ticks, true)
|
||||
}
|
||||
|
||||
// Measure returns the bounds of the axis.
|
||||
func (xa XAxis) Measure(r Renderer, canvasBox Box, ra Range, ticks []Tick) Box {
|
||||
defaultFont, _ := GetDefaultFont()
|
||||
r.SetFont(xa.Style.GetFont(defaultFont))
|
||||
r.SetFontSize(xa.Style.GetFontSize(DefaultFontSize))
|
||||
func (xa XAxis) Measure(r Renderer, canvasBox Box, ra Range, defaults Style, ticks []Tick) Box {
|
||||
r.SetStrokeColor(xa.Style.GetStrokeColor(defaults.StrokeColor))
|
||||
r.SetStrokeWidth(xa.Style.GetStrokeWidth(defaults.StrokeWidth))
|
||||
r.SetFont(xa.Style.GetFont(defaults.GetFont()))
|
||||
r.SetFontColor(xa.Style.GetFontColor(DefaultAxisColor))
|
||||
r.SetFontSize(xa.Style.GetFontSize(defaults.GetFontSize()))
|
||||
|
||||
sort.Sort(Ticks(ticks))
|
||||
|
||||
|
|
@ -133,19 +108,17 @@ func (xa XAxis) Measure(r Renderer, canvasBox Box, ra Range, ticks []Tick) Box {
|
|||
}
|
||||
|
||||
// Render renders the axis
|
||||
func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, ticks []Tick) {
|
||||
tickFontSize := xa.Style.GetFontSize(DefaultFontSize)
|
||||
|
||||
r.SetStrokeColor(xa.Style.GetStrokeColor(DefaultAxisColor))
|
||||
r.SetStrokeWidth(xa.Style.GetStrokeWidth(DefaultAxisLineWidth))
|
||||
func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, defaults Style, ticks []Tick) {
|
||||
r.SetStrokeColor(xa.Style.GetStrokeColor(defaults.StrokeColor))
|
||||
r.SetStrokeWidth(xa.Style.GetStrokeWidth(defaults.StrokeWidth))
|
||||
r.SetFont(xa.Style.GetFont(defaults.GetFont()))
|
||||
r.SetFontColor(xa.Style.GetFontColor(DefaultAxisColor))
|
||||
r.SetFontSize(xa.Style.GetFontSize(defaults.GetFontSize()))
|
||||
|
||||
r.MoveTo(canvasBox.Left, canvasBox.Bottom)
|
||||
r.LineTo(canvasBox.Right, canvasBox.Bottom)
|
||||
r.Stroke()
|
||||
|
||||
r.SetFontColor(xa.Style.GetFontColor(DefaultAxisColor))
|
||||
r.SetFontSize(tickFontSize)
|
||||
|
||||
sort.Sort(Ticks(ticks))
|
||||
|
||||
for _, t := range ticks {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue