adding lastvalueprovider interface and relevant methods.
This commit is contained in:
parent
c14ab6a4b2
commit
2603c67e10
|
@ -31,6 +31,11 @@ func (cs ContinuousSeries) GetValue(index int) (float64, float64) {
|
|||
return cs.XValues[index], cs.YValues[index]
|
||||
}
|
||||
|
||||
// GetLastValue gets the last value.
|
||||
func (cs ContinuousSeries) GetLastValue() (float64, float64) {
|
||||
return cs.XValues[len(cs.XValues)-1], cs.YValues[len(cs.YValues)-1]
|
||||
}
|
||||
|
||||
// GetValueFormatters returns value formatter defaults for the series.
|
||||
func (cs ContinuousSeries) GetValueFormatters() (x, y ValueFormatter) {
|
||||
x = FloatValueFormatter
|
||||
|
|
|
@ -52,7 +52,7 @@ func (ema EMASeries) GetSigma() float64 {
|
|||
}
|
||||
|
||||
// GetValue gets a value at a given index.
|
||||
func (ema EMASeries) GetValue(index int) (x float64, y float64) {
|
||||
func (ema EMASeries) GetValue(index int) (x, y float64) {
|
||||
if ema.InnerSeries == nil {
|
||||
return
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func (ema EMASeries) GetValue(index int) (x float64, y float64) {
|
|||
|
||||
// GetLastValue computes the last moving average value but walking back window size samples,
|
||||
// and recomputing the last moving average chunk.
|
||||
func (ema EMASeries) GetLastValue() (x float64, y float64) {
|
||||
func (ema EMASeries) GetLastValue() (x, y float64) {
|
||||
if ema.InnerSeries == nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func (sma SMASeries) Len() int {
|
|||
}
|
||||
|
||||
// GetValue gets a value at a given index.
|
||||
func (sma SMASeries) GetValue(index int) (x float64, y float64) {
|
||||
func (sma SMASeries) GetValue(index int) (x, y float64) {
|
||||
if sma.InnerSeries == nil {
|
||||
return
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (sma SMASeries) GetValue(index int) (x float64, y float64) {
|
|||
|
||||
// GetLastValue computes the last moving average value but walking back window size samples,
|
||||
// and recomputing the last moving average chunk.
|
||||
func (sma SMASeries) GetLastValue() (x float64, y float64) {
|
||||
func (sma SMASeries) GetLastValue() (x, y float64) {
|
||||
if sma.InnerSeries == nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -29,12 +29,19 @@ func (ts TimeSeries) Len() int {
|
|||
}
|
||||
|
||||
// GetValue gets a value at a given index.
|
||||
func (ts TimeSeries) GetValue(index int) (x float64, y float64) {
|
||||
func (ts TimeSeries) GetValue(index int) (x, y float64) {
|
||||
x = TimeToFloat64(ts.XValues[index])
|
||||
y = ts.YValues[index]
|
||||
return
|
||||
}
|
||||
|
||||
// GetLastValue gets the last value.
|
||||
func (ts TimeSeries) GetLastValue() (x, y float64) {
|
||||
x = TimeToFloat64(ts.XValues[len(ts.XValues)-1])
|
||||
y = ts.YValues[len(ts.YValues)-1]
|
||||
return
|
||||
}
|
||||
|
||||
// GetValueFormatters returns value formatter defaults for the series.
|
||||
func (ts TimeSeries) GetValueFormatters() (x, y ValueFormatter) {
|
||||
x = TimeValueFormatter
|
||||
|
|
|
@ -11,3 +11,13 @@ type BoundedValueProvider interface {
|
|||
Len() int
|
||||
GetBoundedValue(index int) (x, y1, y2 float64)
|
||||
}
|
||||
|
||||
// LastValueProvider is a special type of value provider that can return it's (potentially computed) last value.
|
||||
type LastValueProvider interface {
|
||||
GetLastValue() (x, y float64)
|
||||
}
|
||||
|
||||
// BoundedLastValueProvider is a special type of value provider that can return it's (potentially computed) bounded last value.
|
||||
type BoundedLastValueProvider interface {
|
||||
GetBoundedLastValue(index int) (x, y1, y2 float64)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user