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,6 +1,9 @@
package chart
import "math"
import (
"fmt"
"math"
)
// AnnotationSeries is a series of labels on the chart.
type AnnotationSeries struct {
@ -73,3 +76,11 @@ func (as AnnotationSeries) Render(r Renderer, canvasBox Box, xrange, yrange Rang
}
}
}
// Validate validates the series.
func (as AnnotationSeries) Validate() error {
if len(as.Annotations) == 0 {
return fmt.Errorf("annotation series requires annotations to be set and not empty")
}
return nil
}