ソースを参照

Support specifies that each data marker in the series has a different color

xuri 4 年 前
コミット
1559dd31be
3 ファイル変更19 行追加15 行削除
  1. 3 0
      chart.go
  2. 6 6
      drawing.go
  3. 10 9
      xmlChart.go

+ 3 - 0
chart.go

@@ -494,6 +494,7 @@ func parseFormatChartSet(formatSet string) (*formatChart, error) {
 		Title: formatChartTitle{
 			Name: " ",
 		},
+		VaryColors:   true,
 		ShowBlanksAs: "gap",
 	}
 	err := json.Unmarshal([]byte(formatSet), &format)
@@ -711,6 +712,8 @@ func parseFormatChartSet(formatSet string) (*formatChart, error) {
 //
 // zero: Specifies that blank values shall be treated as zero.
 //
+// Specifies that each data marker in the series has a different color by vary_colors. The default value is true.
+//
 // Set chart offset, scale, aspect ratio setting and print settings by format, same as function AddPicture.
 //
 // Set the position of the chart plot area by plotarea. The properties that can be set are:

+ 6 - 6
drawing.go

@@ -271,7 +271,7 @@ func (f *File) drawBaseChart(formatSet *formatChart) *cPlotArea {
 			Val: stringPtr("clustered"),
 		},
 		VaryColors: &attrValBool{
-			Val: boolPtr(true),
+			Val: boolPtr(formatSet.VaryColors),
 		},
 		Ser:   f.drawChartSeries(formatSet),
 		Shape: f.drawChartShape(formatSet),
@@ -515,7 +515,7 @@ func (f *File) drawDoughnutChart(formatSet *formatChart) *cPlotArea {
 	return &cPlotArea{
 		DoughnutChart: &cCharts{
 			VaryColors: &attrValBool{
-				Val: boolPtr(true),
+				Val: boolPtr(formatSet.VaryColors),
 			},
 			Ser:      f.drawChartSeries(formatSet),
 			HoleSize: &attrValInt{Val: intPtr(75)},
@@ -555,7 +555,7 @@ func (f *File) drawPieChart(formatSet *formatChart) *cPlotArea {
 	return &cPlotArea{
 		PieChart: &cCharts{
 			VaryColors: &attrValBool{
-				Val: boolPtr(true),
+				Val: boolPtr(formatSet.VaryColors),
 			},
 			Ser: f.drawChartSeries(formatSet),
 		},
@@ -568,7 +568,7 @@ func (f *File) drawPie3DChart(formatSet *formatChart) *cPlotArea {
 	return &cPlotArea{
 		Pie3DChart: &cCharts{
 			VaryColors: &attrValBool{
-				Val: boolPtr(true),
+				Val: boolPtr(formatSet.VaryColors),
 			},
 			Ser: f.drawChartSeries(formatSet),
 		},
@@ -584,7 +584,7 @@ func (f *File) drawPieOfPieChart(formatSet *formatChart) *cPlotArea {
 				Val: stringPtr("pie"),
 			},
 			VaryColors: &attrValBool{
-				Val: boolPtr(true),
+				Val: boolPtr(formatSet.VaryColors),
 			},
 			Ser:      f.drawChartSeries(formatSet),
 			SerLines: &attrValString{},
@@ -601,7 +601,7 @@ func (f *File) drawBarOfPieChart(formatSet *formatChart) *cPlotArea {
 				Val: stringPtr("bar"),
 			},
 			VaryColors: &attrValBool{
-				Val: boolPtr(true),
+				Val: boolPtr(formatSet.VaryColors),
 			},
 			Ser:      f.drawChartSeries(formatSet),
 			SerLines: &attrValString{},

+ 10 - 9
xmlChart.go

@@ -553,15 +553,16 @@ type formatChartDimension struct {
 
 // formatChart directly maps the format settings of the chart.
 type formatChart struct {
-	Type      string               `json:"type"`
-	Series    []formatChartSeries  `json:"series"`
-	Format    formatPicture        `json:"format"`
-	Dimension formatChartDimension `json:"dimension"`
-	Legend    formatChartLegend    `json:"legend"`
-	Title     formatChartTitle     `json:"title"`
-	XAxis     formatChartAxis      `json:"x_axis"`
-	YAxis     formatChartAxis      `json:"y_axis"`
-	Chartarea struct {
+	Type       string               `json:"type"`
+	Series     []formatChartSeries  `json:"series"`
+	Format     formatPicture        `json:"format"`
+	Dimension  formatChartDimension `json:"dimension"`
+	Legend     formatChartLegend    `json:"legend"`
+	Title      formatChartTitle     `json:"title"`
+	VaryColors bool                 `json:"vary_colors"`
+	XAxis      formatChartAxis      `json:"x_axis"`
+	YAxis      formatChartAxis      `json:"y_axis"`
+	Chartarea  struct {
 		Border struct {
 			None bool `json:"none"`
 		} `json:"border"`