![](/img/trans.png)
[英]How can I put custom color in High Charts PIE data | Slice and want to change slice text
[英]How can I change the color of the Pie charts using echarts?
我正在使用echarts 。 我想为生成的饼图分配我自己的调色板。 我写了以下代码;
var myChart = echarts.init(document.getElementById('EAR-charts'));
var colorPalette = ['#00b04f', '#ffbf00', 'ff0000']
optionEAR = {
title: {
text: 'Element at Risk',
subtext: 'Pie chart',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
left: 'left',
data: ['Agriculture', 'Builtup', 'Roads']
},
series: [
{
name: 'Element at Risk',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: [
{ value: 335, name: 'Agriculture' },
{ value: 310, name: 'Builtup' },
{ value: 234, name: 'Roads' }
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
],
graph: {
color: colorPalette
}
};
myChart.setOption(optionEAR);
但是颜色没有变化。 但是 output 显示饼图的默认颜色。 如何将饼图的颜色更改为我独特的调色板?
以两种方式添加它会更改 colors。
第一个是:
series: [
...
color: colorPalette,
...
]
第二个是:
series: [
...
],
color: colorPalette,
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.