Debian Codegraph @

concat_series.go

raw symbols SCIP
1 package chart
2
3 // ConcatSeries is a special type of series that concatenates its `InnerSeries`.
4 type ConcatSeries []Series
5
6 // Len returns the length of the concatenated set of series.
7 func (cs ConcatSeries) Len() int {
8 total := 0
9 for _, s := range cs {
10 if typed, isValuesProvider := s.(ValuesProvider); isValuesProvider {
11 total += typed.Len()
12 }
13 }
14
15 return total
16 }
17
18 // GetValue returns the value at the (meta) index (i.e 0 => totalLen-1)
19 func (cs ConcatSeries) GetValue(index int) (x, y float64) {
20 cursor := 0
21 for _, s := range cs {
22 if typed, isValuesProvider := s.(ValuesProvider); isValuesProvider {
23 len := typed.Len()
24 if index < cursor+len {
25 x, y = typed.GetValues(index - cursor) //FENCEPOSTS.
26 return
27 }
28 cursor += typed.Len()
29 }
30 }
31 return
32 }
33
34 // Validate validates the series.
35 func (cs ConcatSeries) Validate() error {
36 var err error
37 for _, s := range cs {
38 err = s.Validate()
39 if err != nil {
40 return err
41 }
42 }
43 return nil
44 }