1,环形图
function echars1(){
var sbcounts = parseInt($('#counts').val());
var sblxcounts = parseInt($('#lxcounts').val());
var zxl = parseInt((sbcounts*100)/(sbcounts+sblxcounts));
option = {
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b}: {c} ({d}%)"
},
series: [
{
name:'设备数',
type:'pie',
radius: ['40%', '60%'], //这里大概是调整大小的
avoidLabelOverlap: false,
center: ['42%', '45%'], //这里大概是调整位置
label: {
normal: {
show: true, //环形中间的字要不要显示
position: 'center'
},
emphasis: {
show: true,
textStyle: {
fontSize: '13',
fontWeight: 'bold'
}
}
},
labelLine: {
normal: {
show: false
}
},
data:[
{value:sbcounts, name:zxl+'%\n在线率',itemStyle: {color: '#84C1FF'}}, //参数依次为 :值,显示的值,类别颜色
{value:sblxcounts, name:'',itemStyle: {color: '#8E8E8E'}},
]
}
]
};
var mychars1 = document.getElementById('mychars1');
echarts.init(mychars1).setOption(option);
}