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

pie扇区颜色无法固定 #48

Closed
ms8922 opened this issue Jan 15, 2020 · 2 comments
Closed

pie扇区颜色无法固定 #48

ms8922 opened this issue Jan 15, 2020 · 2 comments

Comments

@ms8922
Copy link

ms8922 commented Jan 15, 2020

指定了颜色后 每次刷新 扇区的颜色都会随机变化 看了下源码是因为 range map无序的原因导致的
建议Add方法增加一个数组key 来保证顺序

func (c *Pie) Add(name string, data map[string]interface{},keys []string, options ...seriesOptser) *Pie {
nvs := make([]datatypes.NameValueItem, 0)
if keys==nil{
keys= make([]string, 0)
for k, _ := range data {
keys = append(keys, k)
}
}
for _, v := range keys {
nvs = append(nvs, datatypes.NameValueItem{Name: v, Value: data[v]})
}
series := singleSeries{Name: name, Type: ChartType.Pie, Data: nvs}
series.setSingleSeriesOpts(options...)
c.Series = append(c.Series, series)
c.setColor(options...)
return c
}

@chenjiandongx
Copy link
Member

chenjiandongx commented Jan 18, 2020

嗯,确实会出现你描述的问题,但新增参数看起来会破坏兼容性

@chenjiandongx
Copy link
Member

image

v2 版本可以通过设置 Itemstyle 的 color 选项来设置颜色

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants