From 73cc4bd44933994ffa8efad9c3e05fe7cb826b49 Mon Sep 17 00:00:00 2001 From: Artem Tarasenko <Beeb0p@users.noreply.github.com> Date: Tue, 13 Sep 2022 19:05:05 +0300 Subject: This closes #1345, support set custom line color in the charts (#1346) --- drawing.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'drawing.go') diff --git a/drawing.go b/drawing.go index 59b6d2a..e05c9be 100644 --- a/drawing.go +++ b/drawing.go @@ -768,6 +768,16 @@ func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer { // drawChartSeriesSpPr provides a function to draw the c:spPr element by given // format sets. func (f *File) drawChartSeriesSpPr(i int, formatSet *formatChart) *cSpPr { + var srgbClr *attrValString + var schemeClr *aSchemeClr + + if color := stringPtr(formatSet.Series[i].Line.Color); *color != "" { + *color = strings.TrimPrefix(*color, "#") + srgbClr = &attrValString{Val: color} + } else { + schemeClr = &aSchemeClr{Val: "accent" + strconv.Itoa((formatSet.order+i)%6+1)} + } + spPrScatter := &cSpPr{ Ln: &aLn{ W: 25400, @@ -779,7 +789,8 @@ func (f *File) drawChartSeriesSpPr(i int, formatSet *formatChart) *cSpPr { W: f.ptToEMUs(formatSet.Series[i].Line.Width), Cap: "rnd", // rnd, sq, flat SolidFill: &aSolidFill{ - SchemeClr: &aSchemeClr{Val: "accent" + strconv.Itoa((formatSet.order+i)%6+1)}, + SchemeClr: schemeClr, + SrgbClr: srgbClr, }, }, } -- cgit v1.2.1