1. 程式人生 > >如何給eCharts餅圖區域指定顏色

如何給eCharts餅圖區域指定顏色

在option中增加屬性color,並指定幾種顏色,此顏色將根據餅圖的區域個數迴圈,程式碼段如下:

option = {
        title : {
        text: '全域性指標狀態分佈圖',
               x:'left',
               y:'top'
        },
        tooltip : {
               show: true,
               formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        color:['red', 'green','yellow','blueviolet']
}

執行效果如圖所示: