This closes #1910, fix a v2.8.1 regression bug introduced by commit 866f3086cd

- Fix spark lines duplicate when creating spark lines on multiple sheets
This commit is contained in:
xuri 2024-05-29 21:05:34 +08:00
parent 08d25006f9
commit c349313850
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
1 changed files with 339 additions and 337 deletions

View File

@ -18,9 +18,10 @@ import (
"strings"
)
// sparklineGroupPresets defined the list of sparkline group to create
// x14:sparklineGroups element by given sparkline style ID.
var sparklineGroupPresets = []*xlsxX14SparklineGroup{
// getSparklineGroupPresets returns the preset list of sparkline group to create
// x14:sparklineGroups element.
func getSparklineGroupPresets() []*xlsxX14SparklineGroup {
return []*xlsxX14SparklineGroup{
{
ColorSeries: &xlsxColor{Theme: intPtr(4), Tint: -0.499984740745262},
ColorNegative: &xlsxColor{Theme: intPtr(5)},
@ -354,6 +355,7 @@ var sparklineGroupPresets = []*xlsxX14SparklineGroup{
ColorHigh: &xlsxColor{Theme: intPtr(6)},
ColorLow: &xlsxColor{Theme: intPtr(7)},
}, // 36
}
}
// AddSparkline provides a function to add sparklines to the worksheet by
@ -412,7 +414,7 @@ func (f *File) AddSparkline(sheet string, opts *SparklineOptions) error {
}
sparkType = specifiedSparkTypes
}
group = sparklineGroupPresets[opts.Style]
group = getSparklineGroupPresets()[opts.Style]
group.Type = sparkType
group.ColorAxis = &xlsxColor{RGB: "FF000000"}
group.DisplayEmptyCellsAs = "gap"