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 (
// DefaultEMAPeriod is the default EMA period used in the sigma calculation.
DefaultEMAPeriod = 12
@ -99,3 +101,11 @@ func (ema *EMASeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, de
style := ema.Style.InheritFrom(defaults)
Draw.LineSeries(r, canvasBox, xrange, yrange, style, ema)
}
// Validate validates the series.
func (ema *EMASeries) Validate() error {
if ema.InnerSeries == nil {
return fmt.Errorf("ema series requires InnerSeries to be set")
}
return nil
}