Skip to content

Commit 0d67ace

Browse files
committed
Fix Series.Filter regression for assigning series to multiple charts
1 parent 1958b50 commit 0d67ace

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

bar_chart_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func makeBasicBarChartOption() BarChartOption {
1313
seriesList := NewSeriesListDataFromValues([][]float64{
1414
{2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3},
1515
{2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3},
16-
})
16+
}, ChartTypeBar)
1717
for index := range seriesList {
1818
seriesList[index].Label.Show = true
1919
}

series.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type SeriesLabel struct {
5555
// Show flag for label
5656
Show bool
5757
// Distance to the host graphic element.
58-
Distance int
58+
Distance int // TODO - do we want to replace with just Offset?
5959
// Position defines the label position.
6060
Position string
6161
// Offset specifies an offset from the position.
@@ -85,6 +85,7 @@ type SeriesMarkLine struct {
8585
Data []SeriesMarkData
8686
}
8787

88+
// Series references a population of data.
8889
type Series struct {
8990
index int
9091
// Type is the type of series, it can be "line", "bar" or "pie". Default value is "line".
@@ -108,6 +109,10 @@ type Series struct {
108109
// Min value of series
109110
Max *float64
110111
}
112+
113+
// SeriesList is a list of series to be rendered on the chart, typically constructed using NewSeriesListLine,
114+
// NewSeriesListBar, NewSeriesListHorizontalBar, NewSeriesListPie, NewSeriesListRadar, or NewSeriesListFunnel.
115+
// These Series can be appended to each other if multiple chart types should be rendered to the same axis.
111116
type SeriesList []Series
112117

113118
func (sl SeriesList) init() {
@@ -122,7 +127,7 @@ func (sl SeriesList) init() {
122127
func (sl SeriesList) Filter(chartType string) SeriesList {
123128
arr := make(SeriesList, 0)
124129
for index, item := range sl {
125-
if item.Type == "" || item.Type == chartType {
130+
if item.Type == chartType || (chartType == ChartTypeLine && item.Type == "") {
126131
arr = append(arr, sl[index])
127132
}
128133
}
@@ -199,7 +204,7 @@ type seriesSummary struct {
199204
AverageValue float64
200205
}
201206

202-
// Summary get summary of series
207+
// Summary returns numeric summary of series values (population statistics).
203208
func (s *Series) Summary() seriesSummary {
204209
minIndex := -1
205210
maxIndex := -1

0 commit comments

Comments
 (0)