updates + tests
This commit is contained in:
parent
1144b80a46
commit
1555902fc4
13 changed files with 207 additions and 2 deletions
|
|
@ -7,6 +7,14 @@ import (
|
|||
util "github.com/wcharczuk/go-chart/util"
|
||||
)
|
||||
|
||||
// Interface Assertions.
|
||||
var (
|
||||
_ Series = (*TimeSeries)(nil)
|
||||
_ FirstValuesProvider = (*TimeSeries)(nil)
|
||||
_ LastValuesProvider = (*TimeSeries)(nil)
|
||||
_ ValueFormatterProvider = (*TimeSeries)(nil)
|
||||
)
|
||||
|
||||
// TimeSeries is a line on a chart.
|
||||
type TimeSeries struct {
|
||||
Name string
|
||||
|
|
@ -33,14 +41,21 @@ func (ts TimeSeries) Len() int {
|
|||
return len(ts.XValues)
|
||||
}
|
||||
|
||||
// GetValues gets a value at a given index.
|
||||
// GetValues gets x, y values at a given index.
|
||||
func (ts TimeSeries) GetValues(index int) (x, y float64) {
|
||||
x = util.Time.ToFloat64(ts.XValues[index])
|
||||
y = ts.YValues[index]
|
||||
return
|
||||
}
|
||||
|
||||
// GetLastValues gets the last value.
|
||||
// GetFirstValues gets the first values.
|
||||
func (ts TimeSeries) GetFirstValues() (x, y float64) {
|
||||
x = util.Time.ToFloat64(ts.XValues[0])
|
||||
y = ts.YValues[0]
|
||||
return
|
||||
}
|
||||
|
||||
// GetLastValues gets the last values.
|
||||
func (ts TimeSeries) GetLastValues() (x, y float64) {
|
||||
x = util.Time.ToFloat64(ts.XValues[len(ts.XValues)-1])
|
||||
y = ts.YValues[len(ts.YValues)-1]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue