“` //计算值点描述信息 var getLineDesc = function(key, items, filterval){ var xlabels = [] var xVals = [] var yVals = [] var yVals_S1 = [] var avg_S1 = 0 var num_S1 = 0 var avg_S2 = 0 var num_S2 = 0 var yVals_S2 = [] var xVals_num = 10
if (items.length > 0){ var xVals_intv = Math.ceil(items.length/xVals_num) var tag="" if (datafilter_nettype_slow == filterval.eNetType){ tag="2" } //区分值系列 for (var i = 0; i < items.length; i++){ var labelx = items[i].tvSec + "<br>" + "Addr:"+items[i].addr +"/"+ items[i].port + "<br>" + "周期:"+items[i].period +" " +" " + items[i].congesalg xlabels.push(labelx) xVals.push(items[i].tvSec.replace(" ","/n")) var yx = Math.floor((items[i][key+tag] * lineAjustGet(key))*100)/100; yVals.push(yx); if (0 != items[i].optimizing){ avg_S1 += yx; num_S1 ++; yVals_S1.push(yx); yVals_S2.push("-"); }else{ avg_S2 += yx; num_S2 ++; yVals_S1.push("-"); yVals_S2.push(yx); } } } var optPercent = "" var unit = lineUnitGet(key); if (num_S1 > 0){ avg_S1 = Math.floor((avg_S1/num_S1) *100)/100; }else{ avg_S1 = "-" } if (num_S2 > 0){ avg_S2 = Math.floor((avg_S2/num_S2) *100)/100; if (num_S1 > 0){ if ('%' == unit){ optPercent = "(" + Math.ceil((avg_S1 - avg_S2) *100)/100 + "%)"; }else{ optPercent = (((avg_S2 - avg_S1)*100)/avg_S2) optPercent = "(" + Math.ceil(optPercent *100)/100 + "%)"; } } }else{ avg_S2 = "-" } //计算Y周最大最小刻度,和设置的分割数 var defaultYGripNum = 4 var pickThreshold = 0.025 //use 95% data 2 caculate Y Scale Value var ySort = sortArray(yVals); var ymax = 0; var ymin = 0; if (0 != yVals.length) { var tag = Math.ceil(ySort.length * pickThreshold) ymin = ySort[tag]; tag = Math.ceil(ySort.length * ( 1 - pickThreshold)); if (tag >= ySort.length){ tag = ySort.length - 1; } ymax = ySort[tag]; var yIntvl = Math.ceil((ymax - ymin + 1)/(defaultYGripNum - 1)) ymin = ymin - Math.ceil(yIntvl/2) if (ymin < 0){ ymin = 0; }else{ ymin = Math.floor(ymin) } ymax = ymax + Math.ceil(yIntvl/2); ymax = ymin + Math.ceil((ymax - ymin)/defaultYGripNum)*defaultYGripNum; } //赋值出去 var desc = {}; desc.key = key; desc.xVals = xVals; desc.xlabels = xlabels; desc.xVals_intv = xVals_intv; desc.yVals = [yVals_S1, yVals_S2]; desc.ymax = ymax; desc.ymin = ymin; desc.unit = unit; desc.gripNum = defaultYGripNum; desc.sName = [datafilter_optimize_yes +" "+avg_S1+unit + optPercent, datafilter_optimize_no+" "+avg_S2+unit]; return desc;}var allLineChartDo = function(filterval, items){//上层控制函数 if (0 == items.length){ return; }
var tag="" if (datafilter_nettype_slow == filterval.eNetType){ tag="2" } var lineDesc = []; var lineNum = 0; for (var i = 0; i < linelist_info.length; i++){ var key = linelist_info[i][LINE_INFO.KEY]; if (typeof(items[0][key+tag]) != "undefined"){ var desc = getLineDesc(key, items, filterval); desc.seqNum = lineNum + 1; lineDesc[lineNum++] = desc; } } for (var i = 0; i < lineDesc.length; i++){ lineChart(lineDesc[i], filterval) }}“`
新闻热点
疑难解答