标签:配置 tst scroll .ajax UNC i++ document success color
1.
var date=new Date;
var countYear = eval(‘${countForYear}‘);
var countYear1=0;
for (var i = 0; i < countYear.length; i++) {
if(date.getFullYear() == countYear[i].yearNo){
countYear1 = countYear[i].count;
}
}
// echarts设置
// 基于准备好的dom,初始化echarts实例
var yearStatistics = echarts.init(document.getElementById(‘yearStatistics‘));
// 指定图表的配置项和数据
var optionYear = {
title: [{
text: ‘公司各年度投诉反馈情况‘,
left: ‘center‘,
textStyle:{ //设置主标题风格
color:‘green‘
}
},{
subtext: ‘年度投诉反馈:‘,
left: ‘left‘
}],
tooltip: {},
xAxis: {
text:‘11‘,
data: date.getFullYear()-5
},
yAxis: {},
series: [{
name: ‘年份‘,
type: ‘line‘,
data: countYear1
}]
};
yearStatistics.setOption(optionYear);
}
2. 通过ajax获取数据并赋值
var countDept = "";
var dept = [];
var deptContent = [];
$.ajax({
url:‘URL‘,
type:‘post‘,
data:{
nowTime:yearForDept
},
dataType : "json",
success :function(data){
if(data.result == 1){
countDept = eval(data.countForDept);
// 先清空数组
dept.splice(0,dept.length);
deptContent.splice(0,deptContent.length);
for (var i = 0; i < countDept.length; i++) {
dept.push(countDept[i].handlerDept);
deptContent.push({
name:countDept[i].handlerDept,
value:countDept[i].count
})
}
initPieEcharts();
}else{
showErrMsg(yearForDept+"年,查无数据");
return;
}
}
});
function initPieEcharts(){
。。。。。。
legend: {
type: ‘scroll‘,
right: 10,
top: 30,
bottom: 20,
data: dept
},
series : [
{
name:‘投诉反馈比例‘,
type: ‘pie‘,
radius : ‘55%‘,
center: [‘50%‘, ‘50%‘],
selectedMode: ‘single‘,
data: deptContent,
}
]
。。。。。。
}
标签:配置 tst scroll .ajax UNC i++ document success color
原文地址:https://www.cnblogs.com/panyw/p/9172093.html