| 1 |
package chart |
| 2 |
|
| 3 |
import "fmt" |
| 4 |
|
| 5 |
|
| 6 |
func BoundedLastValuesAnnotationSeries(innerSeries FullBoundedValuesProvider, vfs ...ValueFormatter) AnnotationSeries { |
| 7 |
lvx, lvy1, lvy2 := innerSeries.GetBoundedLastValues() |
| 8 |
|
| 9 |
var vf ValueFormatter |
| 10 |
if len(vfs) > 0 { |
| 11 |
vf = vfs[0] |
| 12 |
} else if typed, isTyped := innerSeries.(ValueFormatterProvider); isTyped { |
| 13 |
_, vf = typed.GetValueFormatters() |
| 14 |
} else { |
| 15 |
vf = FloatValueFormatter |
| 16 |
} |
| 17 |
|
| 18 |
label1 := vf(lvy1) |
| 19 |
label2 := vf(lvy2) |
| 20 |
|
| 21 |
var seriesName string |
| 22 |
var seriesStyle Style |
| 23 |
if typed, isTyped := innerSeries.(Series); isTyped { |
| 24 |
seriesName = fmt.Sprintf("%s - Last Values", typed.GetName()) |
| 25 |
seriesStyle = typed.GetStyle() |
| 26 |
} |
| 27 |
|
| 28 |
return AnnotationSeries{ |
| 29 |
Name: seriesName, |
| 30 |
Style: seriesStyle, |
| 31 |
Annotations: []Value2{ |
| 32 |
{XValue: lvx, YValue: lvy1, Label: label1}, |
| 33 |
{XValue: lvx, YValue: lvy2, Label: label2}, |
| 34 |
}, |
| 35 |
} |
| 36 |
} |