![](/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.