如何用echarts创建一个饼图?
1、首先点击左下角开始,找到eclipse,启动eclipse

2、使用requirejs加载echarts插件

3、新建饼图的html,js文件,创建方式如图

4、生成饼图的js代码如下,截图只是部分代码,data部分自己补充数据就可以了
dangerRecType = echarts.init(document.getElementById('dangerRecType'));
dangerRecTypeOption = {
title : {
text : '危险品种类分析',
subtext : '',
x : 'center',
textStyle : {
fontWeight : 'normal',
color : '#06FFFF',
fontSize : 16
}
},
legend : {
data : [],
top : 'bottom',
textStyle : {
color : '#fff'
}
},
tooltip : {
trigger : 'item',
formatter : "{a} <br/>{b}: {c} ({d}%)"
},
series : {
name : '数量',
type : 'pie',
radius : '60%',
center : [ '50%', '50%' ],
data : [],
itemStyle : {
emphasis : {
shadowBlur : 10,
shadowOffsetX : 0,
shadowColor : 'rgba(0, 0, 0, 0.5)'
}
},
label : {
normal : {
show : true,
position : 'inner',
formatter : function(param) {
if (param.percent > 2) {
return param.name;
} else {
return '';
}
},
textStyle : {
color : '#fff',
fontSize : 12
}
}
},
labelLine : {
normal : {
show : true
}
}
}
}
dangerRecType.setOption(dangerRecTypeOption);

5、最终生成的样式如图所示,饼图已经生成
