var allData = resultsData.data;
// X轴数组
var xArray = [];
// Y轴数组
var yArray = [];
//listData
var listData = [];
// 基于准备好的dom,初始化echarts实例
for(var i=0;i0){
data.push(allData[j].num);
}else if(allData[j].education == projectAreaLengend[i] && allData[j].num==0){
data.push(0);
}
}
obj.name = projectAreaLengend[i];
obj.type = "bar";
obj.stack = "总量";
obj.barWidth=15;
obj.barGap="50%";
obj.barBorderRadius=[20,20,0,0];
obj.itemStyle = {normal : {
color: colorList[i],
label : {
textStyle: {
color: '#fff'
},
position: 'inside',
formatter: function(p) {
return p.value > 0 ? (p.value) : '';}
}}};
obj.data = data;
listData.push(obj);
}
var projectAreaData = listData;
var count_num = 0;
for (var m in data){
count_num = count_num +data[m]['value']
}
for (var n in data){
data[n]['name'] = data[n]['name'] + ' '+((data[n]['value']/count_num)*100).toFixed(1) +'%'
}
option = {
tooltip: {
formatter: function(obj){
var retStr = "";
for (var n=0;n ";
}
retStr += obj[n].seriesName+":"+ obj[n].value+"(人)
";
}
retStr += "";
return retStr;
},
//'{b}
{a0}:{c0}个
{a1}:{c1}个
{a2}:{c2}个
{a3}:{c3}个',
trigger: "axis",
axisPointer: {
type: "shadow",
textStyle: {
color: "#fff"
}
},
},
legend : {
data : ["博士","硕士","学士","其他"],
padding : [ 15, 0, 0, 0 ],
},
grid: {
top:'80px',
left: '13%',
textStyle: {
color: "#fff"
}
},
calculable: true,
xAxis: [{
type: "category",
axisLine: {
lineStyle: {
color: '#90979c'
}
},
axisLabel: {
interval: 0,
rotate:30
},
data: projectAreaStaticsYAxis,//名字
}],
yAxis: [{
min:0,
name:"数量(人)",
type: "value",
axisLine: {
lineStyle: {
color: '#90979c'
}
},
axisLabel: {
"interval": 0,
},
}],
//缩放轴
dataZoom: [{
type:"inside",
show: true,
// height: 20,
xAxisIndex: [
0
],
bottom: 0,
start: 0,
end: 27,
handleIcon: ‘path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z’,
handleSize: ‘100%’,
handleStyle:{
color:”#d3dee5”,
},
textStyle:{
color:”#fff”},
borderColor:”#90979c”
}, {
type: “inside”,
show: true,
height: 15,
start: 1,
end: 35
}],
series: projectAreaData
},
myChart.setOption(option);