echarts.init(document.getElementById(id)).setOption({
backgroundColor: '#2c343c', // 背景顏色
textStyle: {
color: 'rgba(255, 255, 255, 0.3)', // 文本顏色
fontSize: 12 // 文本帶下
},
title: {
text: '設備 (ID:'+ title +')', // 標題
x: 'center', // 位置
textStyle: {
color: 'white', // 標題顏色
fontSize: 13 // 標題大小
},
padding: [20, 20, 20, 20] // 通過padding對標題定為
},
series : [
{
type: 'pie', // 指定圖表為餅圖
radius: '50%', // 餅圖相對於容器的大小
center: ['50%', '55%'], // 餅圖相對於容器的位置[左右, 上下]
label: {
normal: {
formatter: "{b}:{d}%", // 文字類型 {a}=> 標題 ,{b} => data中的name,{c} => data中的value,{d} => 百分比
},
},
data:data // 數據,由name和value組成
}
]
});
參考文檔