餅圖
myPovertyVillageCount = echarts.init(document.getElementById('PovertyVillageCount'));
2.配置 optionPovertyVillageCount = {
color: ['#7cb5ec', '#f0ec7d', '#90ec7d', '#f7a35d', '#8085e9', '#ff3d3d', '#00a0e9', '#f603ff', '#00b419', '#5f52a0'],//餅圖塊的顏色
title: {
text: '就失業狀況',
textStyle: {
color: '#fff',
fontSize: 16,
x: 'left'//標題位置,默認left,值有center,right,如果要精確控制位置用top:數值,left:數值
},
backgroundColor: '#2f7abe',
padding: 5//標題邊距,默認5
},//標題的字體顏色背景位置控制
tooltip: {
trigger: 'item',//數據項圖形觸發,主要在散點圖,餅圖等無類目軸的圖表中使用。
formatter: "{b} : {c} ({d}%)"//顯示名稱,數值和百分比,可以回調函數,自己設置裏面的格式
},
series: [
{
name: '就失業狀況',
type: 'pie',
radius: '60%',
center: ['50%', '50%'],
label: {
normal: {
formatter: '{b}: {d}%'//餅圖顯示名稱和百分比 formatter:'{b}'只顯示名稱
}
},//圖形上的文本標籤,可用於說明圖形的一些數據信息,比如值,名稱等
data: povertyHouseholdCount,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}//圖形樣式,有 normal 和 emphasis 兩個狀態。normal 是圖形在默認狀態下的樣式;emphasis 是圖形在高亮狀態下的樣式,比如在鼠標懸浮或者圖例聯動高亮時。
}
]
};
3.指定的數據配置生成圖表 myPovertyVillageCount.setOption(optionPovertyVillageCount)
return val.name.split("-").join("\n");
}