adding validation.

This commit is contained in:
Will Charczuk 2017-02-03 11:26:53 -08:00
parent 3ea3c9ac10
commit e735797037
20 changed files with 285 additions and 7 deletions

View file

@ -1,5 +1,7 @@
package chart
import "fmt"
const (
// DefaultSimpleMovingAveragePeriod is the default number of values to average.
DefaultSimpleMovingAveragePeriod = 16
@ -88,3 +90,11 @@ func (sma SMASeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, def
style := sma.Style.InheritFrom(defaults)
Draw.LineSeries(r, canvasBox, xrange, yrange, style, sma)
}
// Validate validates the series.
func (sma SMASeries) Validate() error {
if sma.InnerSeries == nil {
return fmt.Errorf("sma series requires InnerSeries to be set")
}
return nil
}