diff --git a/bar_chart_test.go b/bar_chart_test.go index fd11868..30b9286 100644 --- a/bar_chart_test.go +++ b/bar_chart_test.go @@ -13,7 +13,7 @@ func makeBasicBarChartOption() BarChartOption { seriesList := NewSeriesListDataFromValues([][]float64{ {2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3}, {2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3}, - }) + }, ChartTypeBar) for index := range seriesList { seriesList[index].Label.Show = true } diff --git a/series.go b/series.go index fbb789b..39a8231 100644 --- a/series.go +++ b/series.go @@ -55,7 +55,7 @@ type SeriesLabel struct { // Show flag for label Show bool // Distance to the host graphic element. - Distance int + Distance int // TODO - do we want to replace with just Offset? // Position defines the label position. Position string // Offset specifies an offset from the position. @@ -85,6 +85,7 @@ type SeriesMarkLine struct { Data []SeriesMarkData } +// Series references a population of data. type Series struct { index int // Type is the type of series, it can be "line", "bar" or "pie". Default value is "line". @@ -108,6 +109,10 @@ type Series struct { // Min value of series Max *float64 } + +// SeriesList is a list of series to be rendered on the chart, typically constructed using NewSeriesListLine, +// NewSeriesListBar, NewSeriesListHorizontalBar, NewSeriesListPie, NewSeriesListRadar, or NewSeriesListFunnel. +// These Series can be appended to each other if multiple chart types should be rendered to the same axis. type SeriesList []Series func (sl SeriesList) init() { @@ -122,7 +127,7 @@ func (sl SeriesList) init() { func (sl SeriesList) Filter(chartType string) SeriesList { arr := make(SeriesList, 0) for index, item := range sl { - if item.Type == "" || item.Type == chartType { + if item.Type == chartType || (chartType == ChartTypeLine && item.Type == "") { arr = append(arr, sl[index]) } } @@ -199,7 +204,7 @@ type seriesSummary struct { AverageValue float64 } -// Summary get summary of series +// Summary returns numeric summary of series values (population statistics). func (s *Series) Summary() seriesSummary { minIndex := -1 maxIndex := -1