前端代码:
var topValue=document.getElementsByName("top")[0].value;
//IM
var myChart = echarts.init(document.getElementById('im'));
//获取json文件的数据放入柱状图中
var username=[];//存储截断后的用户名的数组
var username1=[];//存储原始长度的用户名的数组
var usernameAll1=[];//[i,count],i是第几个用户名的序号,count是次数
var countAll=[];//中间数组
var count=[];
if(ImJson){ //取数据组
for(var i=0;i<ImJson.length;i++){
countAll=[];
if(ImJson[i].username!=null){
username1.push(ImJson[i].username);
}else{
username1.push("未知");
}
if(ImJson[i].username!=null&&getLength(ImJson[i].username)>6){
ImJson[i].username=cutStr(ImJson[i].username,6);
}
if(ImJson[i].username!=null){
username.push(ImJson[i].username);
}else{
username.push("未知");
}
count.push(ImJson[i].count);
countAll.push(i);
countAll.push(ImJson[i].count);
usernameAll1.push(countAll);
}
};
var option = {
title: {
text: 'IM TOP10排名',
left:'40%'
},
animation: false, // 关闭动画效果
legend: {
},
/* toolbox: {
show:true,
feature: {
dataZoom: {
yAxisIndex: 'none'
},
dataView: {readOnly: true},
//magicType: {type: ['line', 'bar']},//折线图、柱状图切换
rest