changing how Draw.LineSeries handles the 0 line

This commit is contained in:
Will Charczuk 2016-07-30 23:14:19 -07:00
parent 6d2a61b790
commit 7b5bb6e952

10
draw.go
View file

@ -22,12 +22,14 @@ func (d draw) LineSeries(r Renderer, canvasBox Box, xrange, yrange Range, style
x0 := cl + xrange.Translate(v0x) x0 := cl + xrange.Translate(v0x)
y0 := cb - yrange.Translate(v0y) y0 := cb - yrange.Translate(v0y)
yv0 := yrange.Translate(0)
var vx, vy float64 var vx, vy float64
var x, y int var x, y int
fill := style.GetFillColor() fill := style.GetFillColor()
if !fill.IsZero() { if !fill.IsZero() {
r.SetFillColor(fill) style.GetFillOptions().WriteToRenderer(r)
r.MoveTo(x0, y0) r.MoveTo(x0, y0)
for i := 1; i < vs.Len(); i++ { for i := 1; i < vs.Len(); i++ {
vx, vy = vs.GetValue(i) vx, vy = vs.GetValue(i)
@ -35,9 +37,9 @@ func (d draw) LineSeries(r Renderer, canvasBox Box, xrange, yrange Range, style
y = cb - yrange.Translate(vy) y = cb - yrange.Translate(vy)
r.LineTo(x, y) r.LineTo(x, y)
} }
r.LineTo(x, cb) r.LineTo(x, Math.MinInt(cb, cb-yv0))
r.LineTo(x0, cb) r.LineTo(x0, Math.MinInt(cb, cb-yv0))
r.Close() r.LineTo(x0, y0)
r.Fill() r.Fill()
} }