adding validation.
This commit is contained in:
parent
3ea3c9ac10
commit
e735797037
20 changed files with 285 additions and 7 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package chart
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TimeSeries is a line on a chart.
|
||||
type TimeSeries struct {
|
||||
|
|
@ -59,3 +62,15 @@ func (ts TimeSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, def
|
|||
style := ts.Style.InheritFrom(defaults)
|
||||
Draw.LineSeries(r, canvasBox, xrange, yrange, style, ts)
|
||||
}
|
||||
|
||||
// Validate validates the series.
|
||||
func (ts TimeSeries) Validate() error {
|
||||
if len(ts.XValues) == 0 {
|
||||
return fmt.Errorf("time series must have xvalues set")
|
||||
}
|
||||
|
||||
if len(ts.YValues) == 0 {
|
||||
return fmt.Errorf("time series must have yvalues set")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue