diff --git a/drawing_helpers.go b/drawing_helpers.go index 8c16704..a38c629 100644 --- a/drawing_helpers.go +++ b/drawing_helpers.go @@ -33,9 +33,7 @@ func DrawLineSeries(r Renderer, canvasBox Box, xrange, yrange Range, s Style, vs } r.SetStrokeColor(s.GetStrokeColor()) - if len(s.GetStrokeDashArray()) > 0 { - r.SetStrokeDashArray(s.GetStrokeDashArray()) - } + r.SetStrokeDashArray(s.GetStrokeDashArray()) r.SetStrokeWidth(s.GetStrokeWidth(DefaultStrokeWidth)) 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.SetStrokeColor(s.GetStrokeColor()) r.SetStrokeWidth(s.GetStrokeWidth()) + r.SetStrokeDashArray(s.GetStrokeDashArray()) textBox := r.MeasureText(label) textWidth := textBox.Width() @@ -132,6 +131,7 @@ func DrawBox(r Renderer, b Box, s Style) { r.SetFillColor(s.GetFillColor()) r.SetStrokeColor(s.GetStrokeColor(DefaultStrokeColor)) r.SetStrokeWidth(s.GetStrokeWidth(DefaultStrokeWidth)) + r.SetStrokeDashArray(s.GetStrokeDashArray()) r.MoveTo(b.Left, b.Top) r.LineTo(b.Right, b.Top) diff --git a/moving_average_series.go b/moving_average_series.go index b408af4..0aa1f53 100644 --- a/moving_average_series.go +++ b/moving_average_series.go @@ -13,6 +13,7 @@ type MovingAverageSeries struct { WindowSize int InnerSeries ValueProvider + valueBuffer *RingBuffer } @@ -44,11 +45,9 @@ func (mas *MovingAverageSeries) GetValue(index int) (x float64, y float64) { if mas.valueBuffer.Len() >= mas.GetWindowSize() { mas.valueBuffer.Dequeue() } - x, y = mas.InnerSeries.GetValue(index) - mas.valueBuffer.Enqueue(y) - if mas.valueBuffer.Len() < mas.GetWindowSize() { - return - } + px, py := mas.InnerSeries.GetValue(index) + mas.valueBuffer.Enqueue(py) + x = px y = mas.getAverage() return }