fixing element crosstalk in raster renderer

This commit is contained in:
Will Charczuk 2016-07-14 10:59:17 -07:00
parent 96e957daaf
commit 61b8b7a785
2 changed files with 7 additions and 8 deletions

View file

@ -33,9 +33,7 @@ func DrawLineSeries(r Renderer, canvasBox Box, xrange, yrange Range, s Style, vs
} }
r.SetStrokeColor(s.GetStrokeColor()) r.SetStrokeColor(s.GetStrokeColor())
if len(s.GetStrokeDashArray()) > 0 { r.SetStrokeDashArray(s.GetStrokeDashArray())
r.SetStrokeDashArray(s.GetStrokeDashArray())
}
r.SetStrokeWidth(s.GetStrokeWidth(DefaultStrokeWidth)) r.SetStrokeWidth(s.GetStrokeWidth(DefaultStrokeWidth))
r.MoveTo(x0, y0) r.MoveTo(x0, y0)
@ -86,6 +84,7 @@ func DrawAnnotation(r Renderer, canvasBox Box, s Style, lx, ly int, label string
r.SetFillColor(s.GetFillColor(DefaultAnnotationFillColor)) r.SetFillColor(s.GetFillColor(DefaultAnnotationFillColor))
r.SetStrokeColor(s.GetStrokeColor()) r.SetStrokeColor(s.GetStrokeColor())
r.SetStrokeWidth(s.GetStrokeWidth()) r.SetStrokeWidth(s.GetStrokeWidth())
r.SetStrokeDashArray(s.GetStrokeDashArray())
textBox := r.MeasureText(label) textBox := r.MeasureText(label)
textWidth := textBox.Width() textWidth := textBox.Width()
@ -132,6 +131,7 @@ func DrawBox(r Renderer, b Box, s Style) {
r.SetFillColor(s.GetFillColor()) r.SetFillColor(s.GetFillColor())
r.SetStrokeColor(s.GetStrokeColor(DefaultStrokeColor)) r.SetStrokeColor(s.GetStrokeColor(DefaultStrokeColor))
r.SetStrokeWidth(s.GetStrokeWidth(DefaultStrokeWidth)) r.SetStrokeWidth(s.GetStrokeWidth(DefaultStrokeWidth))
r.SetStrokeDashArray(s.GetStrokeDashArray())
r.MoveTo(b.Left, b.Top) r.MoveTo(b.Left, b.Top)
r.LineTo(b.Right, b.Top) r.LineTo(b.Right, b.Top)

View file

@ -13,6 +13,7 @@ type MovingAverageSeries struct {
WindowSize int WindowSize int
InnerSeries ValueProvider InnerSeries ValueProvider
valueBuffer *RingBuffer valueBuffer *RingBuffer
} }
@ -44,11 +45,9 @@ func (mas *MovingAverageSeries) GetValue(index int) (x float64, y float64) {
if mas.valueBuffer.Len() >= mas.GetWindowSize() { if mas.valueBuffer.Len() >= mas.GetWindowSize() {
mas.valueBuffer.Dequeue() mas.valueBuffer.Dequeue()
} }
x, y = mas.InnerSeries.GetValue(index) px, py := mas.InnerSeries.GetValue(index)
mas.valueBuffer.Enqueue(y) mas.valueBuffer.Enqueue(py)
if mas.valueBuffer.Len() < mas.GetWindowSize() { x = px
return
}
y = mas.getAverage() y = mas.getAverage()
return return
} }