Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User defined series colors in colStacked chart #1474

Closed
jerrychen113 opened this issue Feb 17, 2023 · 1 comment
Closed

User defined series colors in colStacked chart #1474

jerrychen113 opened this issue Feb 17, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@jerrychen113
Copy link

Description
Hello. We have series line color property work fine. But when I try combo with chart type "colStacked" with multi series, these colors seems too messy.

Steps to reproduce the issue:

var chartSeriesC []excelize.ChartSeries = []excelize.ChartSeries{
	{
		Name:        "Sheet1!$B$38",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$38:$Z$38",
		Line: excelize.ChartLine{
			Color: "FFFF00",
		},
	},
	{
		Name:       "Sheet1!$B$39",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$39:$Z$39",
	},
	{
		Name:       "Sheet1!$B$40",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$40:$Z$40",
	},
	{
		Name:       "Sheet1!$B$41",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$41:$Z$41",
	},
	{
		Name:       "Sheet1!$B$42",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$42:$Z$42",
	},
	{
		Name:       "Sheet1!$B$43",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$43:$Z$43",
	},
	{
		Name:       "Sheet1!$B$44",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$44:$Z$44",
	},
}
var chartSeriesL []excelize.ChartSeries = []excelize.ChartSeries{
	{
		Name:       "Sheet1!$B$45",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$45:$Z$45",
		Line: excelize.ChartLine{
			Color: "FF0000",
		},
		Marker: excelize.ChartMarker{
			Symbol: "none",
		},
	},
	{
		Name:       "Sheet1!$B$46",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$46:$Z$46",
		Marker: excelize.ChartMarker{
			Symbol: "none",
		},
	},
	{
		Name:       "Sheet1!$B$47",
		Categories: "Sheet1!$C$37:$Z$37",
		Values:     "Sheet1!$C$47:$Z$47",
		Marker: excelize.ChartMarker{
			Symbol: "none",
		},
	},
}

excel.AddChart("Sheet1", "K2", &excelize.Chart{
	Type:   "colStacked",
	Series: chartSeriesC,
}, &excelize.Chart{
	Type:   "line",
	Series: chartSeriesL,
})

Describe the results you received:
image

The colStacked in the chart has the default color.

Describe the results you expected:

Defined color by user.

Similar issue:

#1345

Excelize version or commit ID:

(2.7.0)
@xuri xuri added enhancement New feature or request in progress Working in progress labels Feb 17, 2023
@xuri xuri closed this as completed in c2d6707 Feb 17, 2023
@xuri
Copy link
Member

xuri commented Feb 17, 2023

Thanks for your issue. I have add support for set the format for the data series fill. Now you can set the custom solid fill format like this:

var chartSeriesC []excelize.ChartSeries = []excelize.ChartSeries{
    {
        Name:        "Sheet1!$B$38",
        Categories: "Sheet1!$C$37:$Z$37",
        Values:     "Sheet1!$C$38:$Z$38",
+       Fill: excelize.Fill{Type: "pattern", Color: []string{"FFFF00"}, Pattern: 1},
-       Line: excelize.ChartLine{
-           Color: "FFFF00",
-       },
    },

Note that, the Color field in the ChartLine structure has been removed. This feature will be released in the next version.

@xuri xuri removed the in progress Working in progress label Feb 17, 2023
@xuri xuri mentioned this issue Jul 4, 2023
xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
…ill (solid fill)

- Breaking changes: remove the `Color` field in the `ChartLine` structure
- This support set the bubble size in a data series
- Unit test update and correct the docs of the function `GetSheetDimension`
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…ill (solid fill)

- Breaking changes: remove the `Color` field in the `ChartLine` structure
- This support set the bubble size in a data series
- Unit test update and correct the docs of the function `GetSheetDimension`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants