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