bdcontract-web-ide/js/dashboard.js

136 lines
2.7 KiB
JavaScript

var loadDashBoard = function() {
setTimeout(
function() {
var arg1 = {};
arg1.action = "queryUserStat";
global.wssocket.send(JSON.stringify(arg1));
changeLineContractUseTime($("#lineContractUse")[0].value);
listNodes();
}, 500);
};
var changeLineContractUseTime = function(data){
var time = data.split("天")[0];
// console.log(time);
global.lineContractUseTime = time;
setTimeout(function() {
var arg = {};
arg.action = "queryCMLogSimple";
arg.date = new Date().getTime() - 24 * 3600 * 1000 * global.lineContractUseTime;
arg.filter = "executeContract,executeContractOnOtherNodes,pubEvent,executeContractTrustfully";
arg.start = getDateDaysBefore(global.lineContractUseTime);
global.wssocket.send(JSON.stringify(arg));
}, 300);
};
var drawDashBoardCMLog = function(data) {
global.lastData = data;
// console.log(data);
console.log("drawDashBoardCMLog");
$("#dashboardContractExeDiv")
.html(
"<div class='col-12' id='dashboardContractExeCanv' style='min-height: 200px; padding: 0px'></div>");
var xAxisData = data.xAxis;
var pubEventData = data.yAxis1;
var trustData = data.yAxis2;
var wsExecute = data.yAxis3;
var httpExecute = data.yAxis4;
var myChart = echarts.init($("#dashboardContractExeCanv")[0], 'walden');
var option = {
title : {
subtext : '次数'
},
tooltip : {
trigger : 'axis'
},
legend : {
data : [ '事件', '多点执行', 'WS调用', 'HTTP调用' ],
y : 'bottom',
},
toolbox : {
show : true,
feature : {
dataZoom : {
yAxisIndex : 'none'
},
dataView : {
readOnly : false
},
magicType : {
type : [ 'line', 'bar' ]
},
restore : {},
saveAsImage : {}
}
},
xAxis : {
type : 'category',
boundaryGap : false,
data : xAxisData
},
yAxis : {
type : 'value',
axisLabel : {
formatter : '{value}次'
}
},
series : [ {
name : '事件',
type : 'line',
data : pubEventData,
markPoint : {
data : [ {
type : 'max',
name : '最大值'
}, {
type : 'min',
name : '最小值'
} ]
},
}, {
name : '多点执行',
type : 'line',
data : trustData,
markPoint : {
data : [ {
type : 'max',
name : '最大值'
}, {
type : 'min',
name : '最小值'
} ]
}
}, {
name : 'WS调用',
type : 'line',
data : wsExecute,
markPoint : {
data : [ {
type : 'max',
name : '最大值'
}, {
type : 'min',
name : '最小值'
} ]
}
}, {
name : 'HTTP调用',
type : 'line',
data : httpExecute,
markPoint : {
data : [ {
type : 'max',
name : '最大值'
}, {
type : 'min',
name : '最小值'
} ]
}
} ]
};
myChart.setOption(option);
};