@@ -820,14 +820,14 @@ func (f *File) drawChartSeries(opts *Chart) *[]cSer {
820820 Marker : f .drawChartSeriesMarker (k , opts ),
821821 DPt : f .drawChartSeriesDPt (k , opts ),
822822 DLbls : f .drawChartSeriesDLbls (k , opts ),
823- InvertIfNegative : & attrValBool { Val : boolPtr ( false )} ,
823+ InvertIfNegative : f . drawChartSeriesInvertIfNegative ( opts ) ,
824824 Cat : f .drawChartSeriesCat (opts .Series [k ], opts ),
825- Smooth : & attrValBool { Val : boolPtr ( opts . Series [ k ]. Line . Smooth )} ,
825+ Smooth : f . drawChartSeriesSmooth ( k , opts ) ,
826826 Val : f .drawChartSeriesVal (opts .Series [k ], opts ),
827827 XVal : f .drawChartSeriesXVal (opts .Series [k ], opts ),
828828 YVal : f .drawChartSeriesYVal (opts .Series [k ], opts ),
829- BubbleSize : f .drawCharSeriesBubbleSize (opts .Series [k ], opts ),
830- Bubble3D : f .drawCharSeriesBubble3D (opts ),
829+ BubbleSize : f .drawChartSeriesBubbleSize (opts .Series [k ], opts ),
830+ Bubble3D : f .drawChartSeriesBubble3D (opts ),
831831 })
832832 }
833833 return & ser
@@ -854,34 +854,68 @@ func (fill *Fill) drawShapeFill(spPr *cSpPr) *cSpPr {
854854 return spPr
855855}
856856
857- // drawChartSeriesSpPr provides a function to draw the c:spPr element by given
858- // format sets.
859- func (f * File ) drawChartSeriesSpPr (i int , opts * Chart ) * cSpPr {
860- spPr := & cSpPr {SolidFill : & aSolidFill {SchemeClr : & aSchemeClr {Val : "accent" + strconv .Itoa ((opts .order + i )% 6 + 1 )}}}
861- spPr = opts .Series [i ].Fill .drawShapeFill (spPr )
862- solid := & cSpPr {
863- Ln : & aLn {
864- W : ptToEMUs (opts .Series [i ].Line .Width ),
865- Cap : "rnd" , // rnd, sq, flat
866- SolidFill : spPr .SolidFill ,
857+ // drawChartSeriesBubble3D provides a function to draw the c:bubble3D element
858+ // by given format sets.
859+ func (f * File ) drawChartSeriesBubble3D (opts * Chart ) * attrValBool {
860+ if _ , ok := map [ChartType ]bool {Bubble3D : true }[opts .Type ]; ! ok {
861+ return nil
862+ }
863+ return & attrValBool {Val : boolPtr (true )}
864+ }
865+
866+ // drawChartSeriesBubbleSize provides a function to draw the c:bubbleSize
867+ // element by given chart series and format sets.
868+ func (f * File ) drawChartSeriesBubbleSize (v ChartSeries , opts * Chart ) * cVal {
869+ if _ , ok := map [ChartType ]bool {Bubble : true , Bubble3D : true }[opts .Type ]; ! ok {
870+ return nil
871+ }
872+ fVal := v .Values
873+ if v .Sizes != "" {
874+ fVal = v .Sizes
875+ }
876+ return & cVal {
877+ NumRef : & cNumRef {
878+ F : fVal ,
879+ NumCache : & cNumCache {},
867880 },
868881 }
869- if opts .Series [i ].Line .Dash != LineDashUnset {
870- solid .Ln .PrstDash = & attrValString {Val : stringPtr (LineDashTypes [opts .Series [i ].Line .Dash ])}
882+ }
883+
884+ // drawChartSeriesCat provides a function to draw the c:cat element by given
885+ // chart series and format sets.
886+ func (f * File ) drawChartSeriesCat (v ChartSeries , opts * Chart ) * cCat {
887+ cat := & cCat {
888+ StrRef : & cStrRef {
889+ F : v .Categories ,
890+ },
871891 }
872- noLn := & cSpPr {Ln : & aLn {NoFill : & attrValString {}}}
873- if chartSeriesSpPr , ok := map [ChartType ]map [LineType ]* cSpPr {
874- Line : {LineUnset : solid , LineSolid : solid , LineNone : noLn , LineAutomatic : solid },
875- Scatter : {LineUnset : noLn , LineSolid : solid , LineNone : noLn , LineAutomatic : noLn },
876- StockHighLowClose : {LineUnset : noLn , LineSolid : solid , LineNone : noLn , LineAutomatic : noLn },
877- StockOpenHighLowClose : {LineUnset : noLn , LineSolid : solid , LineNone : noLn , LineAutomatic : noLn },
878- }[opts .Type ]; ok {
879- return chartSeriesSpPr [opts .Series [i ].Line .Type ]
892+ chartSeriesCat := map [ChartType ]* cCat {Scatter : nil , Bubble : nil , Bubble3D : nil }
893+ if _ , ok := chartSeriesCat [opts .Type ]; ok || v .Categories == "" {
894+ return nil
880895 }
881- if spPr .SolidFill != nil && spPr .SolidFill .SrgbClr != nil || spPr .NoFill != nil {
882- return spPr
896+ return cat
897+ }
898+
899+ // drawChartSeriesDLbls provides a function to draw the c:dLbls element by
900+ // given format sets.
901+ func (f * File ) drawChartSeriesDLbls (i int , opts * Chart ) * cDLbls {
902+ dLbls := f .drawChartDLbls (opts )
903+ chartSeriesDLbls := map [ChartType ]* cDLbls {
904+ Scatter : nil , Surface3D : nil , WireframeSurface3D : nil , Contour : nil , WireframeContour : nil ,
883905 }
884- return nil
906+ if _ , ok := chartSeriesDLbls [opts .Type ]; ok {
907+ return nil
908+ }
909+ if types , ok := supportedChartDataLabelsPosition [opts .Type ]; ok && opts .Series [i ].DataLabelPosition != ChartDataLabelsPositionUnset {
910+ if inSupportedChartDataLabelsPositionType (types , opts .Series [i ].DataLabelPosition ) != - 1 {
911+ dLbls .DLblPos = & attrValString {Val : stringPtr (chartDataLabelsPositionTypes [opts .Series [i ].DataLabelPosition ])}
912+ }
913+ }
914+ dLbl := opts .Series [i ].DataLabel
915+ dLbls .SpPr = dLbl .Fill .drawShapeFill (dLbls .SpPr )
916+ dLbls .TxPr = & cTxPr {BodyPr : aBodyPr {}, P : aP {PPr : & aPPr {DefRPr : aRPr {}}}}
917+ drawChartFont (& dLbl .Font , & dLbls .TxPr .P .PPr .DefRPr )
918+ return dLbls
885919}
886920
887921// drawChartSeriesDPt provides a function to draw the c:dPt element by given
@@ -923,35 +957,18 @@ func (f *File) drawChartSeriesDPt(i int, opts *Chart) []*cDPt {
923957 return chartSeriesDPt [opts .Type ]
924958}
925959
926- // drawChartSeriesCat provides a function to draw the c:cat element by given
927- // chart series and format sets.
928- func (f * File ) drawChartSeriesCat (v ChartSeries , opts * Chart ) * cCat {
929- cat := & cCat {
930- StrRef : & cStrRef {
931- F : v .Categories ,
932- },
960+ // drawChartSeriesInvertIfNegative provides a function to draw the
961+ // c:invertIfNegative element.
962+ func (f * File ) drawChartSeriesInvertIfNegative (opts * Chart ) * attrValBool {
963+ if opts .Type == Bubble || opts .Type == Bubble3D {
964+ return & attrValBool {Val : boolPtr (false )}
933965 }
934- chartSeriesCat := map [ChartType ]* cCat {Scatter : nil , Bubble : nil , Bubble3D : nil }
935- if _ , ok := chartSeriesCat [opts .Type ]; ok || v .Categories == "" {
936- return nil
937- }
938- return cat
939- }
940-
941- // drawChartSeriesVal provides a function to draw the c:val element by given
942- // chart series and format sets.
943- func (f * File ) drawChartSeriesVal (v ChartSeries , opts * Chart ) * cVal {
944- val := & cVal {
945- NumRef : & cNumRef {
946- F : v .Values ,
947- NumCache : & cNumCache {},
948- },
949- }
950- chartSeriesVal := map [ChartType ]* cVal {Scatter : nil , Bubble : nil , Bubble3D : nil }
951- if _ , ok := chartSeriesVal [opts .Type ]; ok {
952- return nil
966+ for _ , t := range barColChartTypes {
967+ if t == opts .Type {
968+ return & attrValBool {Val : boolPtr (false )}
969+ }
953970 }
954- return val
971+ return nil
955972}
956973
957974// drawChartSeriesMarker provides a function to draw the c:marker element by
@@ -990,6 +1007,61 @@ func (f *File) drawChartSeriesMarker(i int, opts *Chart) *cMarker {
9901007 return chartSeriesMarker [opts .Type ]
9911008}
9921009
1010+ // drawChartSeriesSmooth provides a function to draw the c:smooth element.
1011+ func (f * File ) drawChartSeriesSmooth (i int , opts * Chart ) * attrValBool {
1012+ switch opts .Type {
1013+ case Line , Line3D , Scatter :
1014+ return & attrValBool {Val : boolPtr (opts .Series [i ].Line .Smooth )}
1015+ }
1016+ return nil
1017+ }
1018+
1019+ // drawChartSeriesSpPr provides a function to draw the c:spPr element by given
1020+ // format sets.
1021+ func (f * File ) drawChartSeriesSpPr (i int , opts * Chart ) * cSpPr {
1022+ spPr := & cSpPr {SolidFill : & aSolidFill {SchemeClr : & aSchemeClr {Val : "accent" + strconv .Itoa ((opts .order + i )% 6 + 1 )}}}
1023+ spPr = opts .Series [i ].Fill .drawShapeFill (spPr )
1024+ solid := & cSpPr {
1025+ Ln : & aLn {
1026+ W : ptToEMUs (opts .Series [i ].Line .Width ),
1027+ Cap : "rnd" , // rnd, sq, flat
1028+ SolidFill : spPr .SolidFill ,
1029+ },
1030+ }
1031+ if opts .Series [i ].Line .Dash != LineDashUnset {
1032+ solid .Ln .PrstDash = & attrValString {Val : stringPtr (LineDashTypes [opts .Series [i ].Line .Dash ])}
1033+ }
1034+ noLn := & cSpPr {Ln : & aLn {NoFill : & attrValString {}}}
1035+ if chartSeriesSpPr , ok := map [ChartType ]map [LineType ]* cSpPr {
1036+ Line : {LineUnset : solid , LineSolid : solid , LineNone : noLn , LineAutomatic : solid },
1037+ Scatter : {LineUnset : noLn , LineSolid : solid , LineNone : noLn , LineAutomatic : noLn },
1038+ StockHighLowClose : {LineUnset : noLn , LineSolid : solid , LineNone : noLn , LineAutomatic : noLn },
1039+ StockOpenHighLowClose : {LineUnset : noLn , LineSolid : solid , LineNone : noLn , LineAutomatic : noLn },
1040+ }[opts .Type ]; ok {
1041+ return chartSeriesSpPr [opts .Series [i ].Line .Type ]
1042+ }
1043+ if spPr .SolidFill != nil && spPr .SolidFill .SrgbClr != nil || spPr .NoFill != nil {
1044+ return spPr
1045+ }
1046+ return nil
1047+ }
1048+
1049+ // drawChartSeriesVal provides a function to draw the c:val element by given
1050+ // chart series and format sets.
1051+ func (f * File ) drawChartSeriesVal (v ChartSeries , opts * Chart ) * cVal {
1052+ val := & cVal {
1053+ NumRef : & cNumRef {
1054+ F : v .Values ,
1055+ NumCache : & cNumCache {},
1056+ },
1057+ }
1058+ chartSeriesVal := map [ChartType ]* cVal {Scatter : nil , Bubble : nil , Bubble3D : nil }
1059+ if _ , ok := chartSeriesVal [opts .Type ]; ok {
1060+ return nil
1061+ }
1062+ return val
1063+ }
1064+
9931065// drawChartSeriesXVal provides a function to draw the c:xVal element by given
9941066// chart series and format sets.
9951067func (f * File ) drawChartSeriesXVal (v ChartSeries , opts * Chart ) * cCat {
@@ -1015,33 +1087,6 @@ func (f *File) drawChartSeriesYVal(v ChartSeries, opts *Chart) *cVal {
10151087 return chartSeriesYVal [opts .Type ]
10161088}
10171089
1018- // drawCharSeriesBubbleSize provides a function to draw the c:bubbleSize
1019- // element by given chart series and format sets.
1020- func (f * File ) drawCharSeriesBubbleSize (v ChartSeries , opts * Chart ) * cVal {
1021- if _ , ok := map [ChartType ]bool {Bubble : true , Bubble3D : true }[opts .Type ]; ! ok {
1022- return nil
1023- }
1024- fVal := v .Values
1025- if v .Sizes != "" {
1026- fVal = v .Sizes
1027- }
1028- return & cVal {
1029- NumRef : & cNumRef {
1030- F : fVal ,
1031- NumCache : & cNumCache {},
1032- },
1033- }
1034- }
1035-
1036- // drawCharSeriesBubble3D provides a function to draw the c:bubble3D element
1037- // by given format sets.
1038- func (f * File ) drawCharSeriesBubble3D (opts * Chart ) * attrValBool {
1039- if _ , ok := map [ChartType ]bool {Bubble3D : true }[opts .Type ]; ! ok {
1040- return nil
1041- }
1042- return & attrValBool {Val : boolPtr (true )}
1043- }
1044-
10451090// drawChartNumFmt provides a function to draw the c:numFmt element by given
10461091// data labels format sets.
10471092func (f * File ) drawChartNumFmt (labels ChartNumFmt ) * cNumFmt {
@@ -1082,28 +1127,6 @@ func inSupportedChartDataLabelsPositionType(a []ChartDataLabelPositionType, x Ch
10821127 return - 1
10831128}
10841129
1085- // drawChartSeriesDLbls provides a function to draw the c:dLbls element by
1086- // given format sets.
1087- func (f * File ) drawChartSeriesDLbls (i int , opts * Chart ) * cDLbls {
1088- dLbls := f .drawChartDLbls (opts )
1089- chartSeriesDLbls := map [ChartType ]* cDLbls {
1090- Scatter : nil , Surface3D : nil , WireframeSurface3D : nil , Contour : nil , WireframeContour : nil ,
1091- }
1092- if _ , ok := chartSeriesDLbls [opts .Type ]; ok {
1093- return nil
1094- }
1095- if types , ok := supportedChartDataLabelsPosition [opts .Type ]; ok && opts .Series [i ].DataLabelPosition != ChartDataLabelsPositionUnset {
1096- if inSupportedChartDataLabelsPositionType (types , opts .Series [i ].DataLabelPosition ) != - 1 {
1097- dLbls .DLblPos = & attrValString {Val : stringPtr (chartDataLabelsPositionTypes [opts .Series [i ].DataLabelPosition ])}
1098- }
1099- }
1100- dLbl := opts .Series [i ].DataLabel
1101- dLbls .SpPr = dLbl .Fill .drawShapeFill (dLbls .SpPr )
1102- dLbls .TxPr = & cTxPr {BodyPr : aBodyPr {}, P : aP {PPr : & aPPr {DefRPr : aRPr {}}}}
1103- drawChartFont (& dLbl .Font , & dLbls .TxPr .P .PPr .DefRPr )
1104- return dLbls
1105- }
1106-
11071130// drawPlotAreaCatAx provides a function to draw the c:catAx element.
11081131func (f * File ) drawPlotAreaCatAx (pa * cPlotArea , opts * Chart ) []* cAxs {
11091132 maxVal := & attrValFloat {Val : opts .XAxis .Maximum }
0 commit comments