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" "strings"
) )
// sparklineGroupPresets defined the list of sparkline group to create // getSparklineGroupPresets returns the preset list of sparkline group to create
// x14:sparklineGroups element by given sparkline style ID. // x14:sparklineGroups element.
var sparklineGroupPresets = []*xlsxX14SparklineGroup{ func getSparklineGroupPresets() []*xlsxX14SparklineGroup {
return []*xlsxX14SparklineGroup{
{ {
ColorSeries: &xlsxColor{Theme: intPtr(4), Tint: -0.499984740745262}, ColorSeries: &xlsxColor{Theme: intPtr(4), Tint: -0.499984740745262},
ColorNegative: &xlsxColor{Theme: intPtr(5)}, ColorNegative: &xlsxColor{Theme: intPtr(5)},
@ -355,6 +356,7 @@ var sparklineGroupPresets = []*xlsxX14SparklineGroup{
ColorLow: &xlsxColor{Theme: intPtr(7)}, ColorLow: &xlsxColor{Theme: intPtr(7)},
}, // 36 }, // 36
} }
}
// AddSparkline provides a function to add sparklines to the worksheet by // AddSparkline provides a function to add sparklines to the worksheet by
// given formatting options. Sparklines are small charts that fit in a single // given formatting options. Sparklines are small charts that fit in a single
@ -412,7 +414,7 @@ func (f *File) AddSparkline(sheet string, opts *SparklineOptions) error {
} }
sparkType = specifiedSparkTypes sparkType = specifiedSparkTypes
} }
group = sparklineGroupPresets[opts.Style] group = getSparklineGroupPresets()[opts.Style]
group.Type = sparkType group.Type = sparkType
group.ColorAxis = &xlsxColor{RGB: "FF000000"} group.ColorAxis = &xlsxColor{RGB: "FF000000"}
group.DisplayEmptyCellsAs = "gap" group.DisplayEmptyCellsAs = "gap"