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

How can I set the Fill color for pie chart ? #1904

Closed
Kerlli opened this issue May 23, 2024 · 2 comments
Closed

How can I set the Fill color for pie chart ? #1904

Kerlli opened this issue May 23, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@Kerlli
Copy link

Kerlli commented May 23, 2024

Description

Hi, Maintainers

How can I set the Fill color for each part of pie chart ?

Like:

for idx, row := range [][]interface{}{
        {"Apple", "Orange", "Pear"},
        {2, 3, 3},
    } {
        cell, err := excelize.CoordinatesToCellName(1, idx+1)
        if err != nil {
            fmt.Println(err)
            return
        }
        if err := f.SetSheetRow("Sheet1", cell, &row); err != nil {
            fmt.Println(err)
            return
        }
    }

if err := f.AddChart("Sheet1", "E1", &excelize.Chart{
        Type: excelize.Pie,
        Series: []excelize.ChartSeries{
            {
                Name:       "Amount",
                Categories: "Sheet1!$A$1:$C$1",
                Values:     "Sheet1!$A$2:$C$2",
            },
        },
        Title: []excelize.RichTextRun{
            {
                Text: "Fruit Pie Chart",
            },
        },
    }); err != nil {
        fmt.Println(err)
        return
    }

I'm wondering about how to set colors for Apple, Orange and Pear

Thanks.

Steps to reproduce the issue:

Describe the results you received:

Each series fill color can only be set by:

excelize.ChartSeries{
	Fill: excelize.Fill{
		Type:    "pattern",
		Color:   []string{"#505050"},
		Pattern: 1,
	},
}

Describe the results you expected:

Output of go version:

v1.22

Excelize version or commit ID:

2.8.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):

@xuri xuri added the duplicate This issue or pull request already exists label May 24, 2024
@xuri
Copy link
Member

xuri commented May 24, 2024

Duplicated with #1862.

@xuri
Copy link
Member

xuri commented Jun 4, 2024

I closed this issue, and keep #1862 to track this feature request, if you have any questions, please let me know to reopen this anytime.

@xuri xuri closed this as completed Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants