getUserId();
var RedRank = (function() {
this.fetchPos = 0;
this.loader = (function () {
this.load = function(pos) {
get_data(`fcBiWorkerDaily/get?type=${RedRank.fetchPos}`, RedRank.loader.onSuccess);
};
this.consecutiveLoad = function(){
RedRank.fetchPos = (RedRank.fetchPos + 1) % 8;
load(RedRank.fetchPos);
};
this.onSuccess = function(res, code){
};
})();
})();
var RANK_TBL_ROW_COUNT = 4;
var goodColor = [];
var badColor = [];
var goodColor1 = [];
var badColor1 = [];
var userIDs = [];
var schedulepass = 0, schedulefail = 0, schedulestack = 0;
var todayotherpass = 0, todayotherfail = 0, todayotherstack = 0;
var lastTimeHistory = "";
var histoires = [];
var hispass = [];
var hisfail = [];
var hisstack = [];
var hisrate = [];
var goodpass = [];
var goodid = [];
var goodfailrate = [];
var goodpass1 = [];
var goodid1 = [];
var goodfailrate1 = [];
var badpass = [];
var badid = [];
var badfailrate = [];
var badpass1 = [];
var badid1 = [];
var badfailrate1 = [];
function history_success(obj, sta) {
var histoire = first_parse(this, obj);
var i, j, t;
console.log(" histoire : ");
console.log(histoire);
if (this.url.indexOf("type=1") >= 0) {
t = 1;
} else if (this.url.indexOf("type=2") >= 0) {
t = 2;
} else if (this.url.indexOf("type=3") >= 0) {
t = 3;
} else {
t = 0;
return;
}
histoires[t] = histoire;
if (t === 2 || t === 3) {
hispass[t] = 0;
hisfail[t] = 0;
hisstack[t] = 0;
hisrate[t] = 0;
for (i = 0; i < histoire.length - 1; i++) { //除了今日
hispass[t] = histoire[i].passNum + hispass[t];
hisfail[t] = histoire[i].failNum + hisfail[t];
hisstack[t] = histoire[i].avgDue + hisstack[t];
}
orighispass[t] = hispass[t];
orighisfail[t] = hisfail[t];
orighisstack[t] = hisstack[t];
hispass[t] += hispass[0];
hisfail[t] += hisfail[0];
hisstack[t] += hisstack[0];
hisrate[t] = get_factor(hispass[t], hisfail[t]);
} else if (t === 1) {
hispass[1] = histoire[0].passNum;
hisfail[1] = histoire[0].failNum;
hisstack[1] = histoire[0].avgDue;
hisrate[t] = get_factor(hispass[1], hisfail[1]);
}
todayotherpass = histoire[histoire.length - 1].passNum;
todayotherfail = histoire[histoire.length - 1].failNum;
todayotherstack = histoire[histoire.length - 1].avgDue;
update_all_history();
}
function update_all_history() {
hispass[0] = todayotherpass + schedulepass;
hisfail[0] = todayotherfail + schedulefail;
hisstack[0] = todayotherstack + schedulestack;
hisrate[0] = get_factor(hispass[0], hisfail[0]);
if (typeof hisrate[0] == "undefined" || isNaN(hisrate[0])) {
send_alert("请重试!");
}
for (i = 2; i <= 3; i++) {
hispass[i] = orighispass[i] + hispass[0];
hisfail[i] = orighisfail[i] + hisfail[0];
hisstack[i] = orighisstack[i] + hisstack[0];
hisrate[i] = get_factor(hispass[i], hisfail[i]);
}
}
var todayotherpass, todayotherfail, todayotherstack;
var orighisfail = [], orighispass = [], orighisstack = [];
function isUserOfThisFlow(uid) {
var isExist = false;
userIDs.forEach(function (vals) {
if (vals == uid) {
isExist = true;
}
});
return isExist;
}
function on_red_rank_success(obj, sta) {
var redchart = first_parse(this, obj);
var i, j;
i = j = 0;
console.log(" redchart : ");
console.log(redchart);
for (i = 0; i < redchart.list.length; i++) {
goodid[i] = getUserName(redchart.list[i].workerId);
goodpass[i] = redchart.list[i].passNum;
if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
goodfailrate[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
} else {
goodfailrate[i] = 0;
}
if (isUserOfThisFlow(redchart.list[i].workerId)) {
goodColor[i] = 'red';
} else {
goodColor[i] = '';
}
}
}
function on_red_rank_success1(obj, sta) {
var redchart = first_parse(this, obj);
var i, j;
i = j = 0;
console.log(" redchart : ");
console.log(redchart);
for (i = 0; i < redchart.list.length; i++) {
goodid1[i] = getUserName(redchart.list[i].workerId);
goodpass1[i] = redchart.list[i].passNum;
if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
goodfailrate1[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
} else {
goodfailrate1[i] = 0;
}
if (isUserOfThisFlow(redchart.list[i].workerId)) {
goodColor1[i] = 'red';
} else {
goodColor1[i] = '';
}
}
}
function on_black_rank_success(obj, sta) {
var blackchart = first_parse(this, obj);
var i, j;
i = j = 0;
console.log(" black chart : ");
console.log(blackchart);
for (i = 0; i < blackchart.list.length; i++) {
badid[i] = getUserName(blackchart.list[i].workerId);
badpass[i] = blackchart.list[i].passNum;
//badfailrate[i] = blackchart.list[i].failRate / 100;
if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
badfailrate[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
} else {
badfailrate[i] = 0;
}
if (isUserOfThisFlow(blackchart.list[i].workerId)) {
badColor[i] = 'green';
} else {
badColor[i] = '';
}
}
}
function on_black_rank_success1(obj, sta) {
var blackchart = first_parse(this, obj);
var i, j;
i = j = 0;
console.log(" black chart : ");
console.log(blackchart);
for (i = 0; i < blackchart.list.length; i++) {
badid1[i] = getUserName(blackchart.list[i].workerId);
badpass1[i] = blackchart.list[i].passNum;
//badfailrate[i] = blackchart.list[i].failRate / 100;
if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
badfailrate1[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
} else {
badfailrate1[i] = 0;
}
if (isUserOfThisFlow(blackchart.list[i].workerId)) {
badColor1[i] = 'green';
} else {
badColor1[i] = '';
}
}
}
function getHistoryTableBody(htmlbody, i) {
if (typeof hispass[i] === "undefined") {
htmlbody += "
";
htmlbody += `
| - |
- |
- |
- |
- |
`;
htmlbody += "";
return htmlbody;
}
htmlbody += "";
htmlbody += `
| ${timeday[i]} |
${hispass[i]} |
${hisfail[i]} |
${hisstack[i]} |
${hisrate[i] + '%'} |
`;
htmlbody += "";
return htmlbody;
}
function getRankingTableBody(htmlbody, i) {
if (typeof goodRank === "undefined" || typeof goodRank[i] === "undefined") {
htmlbody += "";
htmlbody += `
| - |
0 |
0 |
0 |
`;
htmlbody += "";
return htmlbody;
}
htmlbody += "";
htmlbody += `
| ${goodRank[i].id} |
${goodRank[i].pass} |
${goodRank[i].fail} |
${goodRank[i].failRate + '%'} |
`;
htmlbody += "";
return htmlbody;
}
var lastTimeRank0 = "";
var lastTimeRank1 = "";
var lastTimeRank2 = "";
var lastTimeRank3 = "";
var lastTimeRank4 = "";
function showHistoryData() {
var htmlbody = "", one_person = "";
var i = 0;
var triGap = 4;
htmlbody = "";
for (i = 0; i < triGap; i++) {
htmlbody = getHistoryTableBody(htmlbody, i);
}
if (lastTimeRank0 !== htmlbody) {
$("#rank-one").html(htmlbody);
lastTimeRank0 = htmlbody;
}
//console.log(htmlbody);
}
function showRedRanking() {
var htmlbody = "", one_person = "";
var i = 0;
var triGap = RANK_TBL_ROW_COUNT;
htmlbody = "";
for (i = 0; i < triGap; i++) {
htmlbody = getRankingTableBody(htmlbody, i);
}
if (lastTimeRank1 !== htmlbody) {
$("#rank-two").html(htmlbody);
lastTimeRank1 = htmlbody;
}
//console.log(htmlbody);
}
/***
* DataObject DO
* @param cname
* @param serverJsonObj
* @constructor
*/
var DataObject = function(cname, serverJsonObj){
this.ctlName = cname;
this.jsonObj = serverJsonObj;
this.getVal = function (key) {
return jsonObj[key];
};
this.serVal = function (key, val) {
jsonObj[key] = val;
};
};
/***
* DataObjectList
* @param name
* @constructor
*/
var DataObjectList = function(name){
this.ctlName = name;
this.list = null;
this.isSorted = false;
this.preSort = [];
/***
* sorting
* @param comparator (a,b) =====> a - b
*/
this.sortBy = function(comparator){
preSort = new Array();
for (let i = 0; i < list.length; i++) preSort.push(list[i]);
quickSort(preSort, 0, preSort.length - 1, function(l, r){});
};
function clearData() {
isSorted = false;
preSort = null;
list = null;
}
this.len = function() {
if(list == null) return 0;
return list.length;
};
this.assignJsonData = function (data) {
clearData();
list = new Array();
for (let i = 0; i < list.length; i++) list.push(new DataObject(ctlName, data[i]));
};
this.getRaw = function (index) {
return list[index];
};
this.getSorted = function (index) {
if(!isSorted) return null;
return preSort[index];
};
this.quickSort = function (a,left,right,comp){
if(left>right){ //一定要有这个判断,因为有递归left和i-1,若没有这个判断条件,该函数会进入无限死错位递归
return;
}
var i=left,
j=right,
pivot=a[left]; //基准总是取序列开头的元素
while(i!=j){
while((comp(a[j],pivot) > 0)&&i 100){
this.failedCount = 0;
this.stopTimers();
console.log("【错误次数过多");
setTimeout(this.setUpInterval, 10000);
}
if(this.failedCount == 2) {
send_alert("没有数据,请尝试重新加载!【DataService】: ctlName[" + controlName + "], extParm[" + extparm + "]");
}
}else{
this.list.assignJsonData(output.list);
}
};
this.passiveUpdate = function(data){
this.failedCount = 0;
this.list.assignJsonData(data);
};
this.init();
};
var SinglePage = function () {
this.modules = [];
};
var Module = function(chartContainerSelector, dataCtlName){
this.selector = chartContainerSelector;
this.dataCtl = dataCtlName;
this.activeData = null;
this.lastActive = 0;
/***
* bindData to UI
* @param data DataObjectList
*/
this.setData = function (data) {
if(data.ctlName == this.dataCtl){
//ok
console.log(`-------- Module ${this.selector} got data ----------- `);
this.activeData = data;
//cache
this.drawData();
}else{
console.log(`-------- Module ${this.selector} cannot use data of ${data.ctlName} ----------- `);
}
};
this.drawData = function () {
// do nothing
}
};
var RealTimeGraph = new Module("", "fcBiSectorLoad");
RealTimeGraph.drawData = function (data) {
var tempo = this.activeData;
};
var FlowRealTime = (function () {
this.pgName = "flowDashBoard";
this.page = new SinglePage(this.pgName);
this.scheduleId = utils_get_param("scheduleId");
this.flowId = utils_get_param("flowId");
if(scheduleId == null || flowId == null)
{
send_alert(`清重新进入本页面! 返回主页 `);
return;
}
this.flowPlace = " % flowPlace %";
this.flowName = " % flowPlace %";
this.HistoryBaseURL = "fcBiFlowDaily/list?scheduleId=" + scheduleId + "&flowId=" + flowId;
this.scheduleLoadDataService = new DataObjectService("fcScheduleLoadService", 2 & 4);
this.biFlowDailyService = null;
this.oaStaffService = null;
this.sectorService = null;
this.flowService = null;
this.initializeUsers = function(list){
list.forEach(function (val, it, arr) {
var isExist = false;
userIDs.forEach(function (vals) {
if (vals == val.userId) {
isExist = true;
}
});
if (!isExist) userIDs.push(val.userId);
});
};
this.initPage = function(){
showHistoryData();
showRedRanking();
showBlackRanking();
};
/***
* On
* @param obj
* @param sta
*/
this.onFirstTimeSuccess = function (obj, sta) {
let output = first_parse(this, obj);
let i, j, k, z = 0, x = 0, worksum = [];
if (output.list == undefined || output.list.length == 0) {
send_alert("没有数据 | 请重新加载页面 ! ");
}else{
DataLogic.onScheduleData(output.list);
}
initializeUsers(output.list);
Action.loadMultiHistory();
showChart();
};
/**
* DataLogic
*/
this.DataLogic = (function () {
this.combineAsSector = function(sectorList, scheduleDoList) {
var output = new DataObjectList("sectorLoad");
output.assignJsonData("");
return output;
};
this.onScheduleData = function (scheduleDoList) {
sectorID[0] = getSectorId(scheduleDoList[0].spotId);
for (let i = 1; i < scheduleDoList.length; i++) {
let loadDO = new ScheduleDO(scheduleDoList[i]);
x = 0;
for (j = 0; j < sectorID.length; j++) {
if (sectorID[j] === thisUid) {
x = 1;
break;
}
}
if (x === 0) {
sectorID.push(thisUid);
}
}
DataLogic.CountBySector();
}
this.CountBySector = function (sectors, spotData) {
sectorId, passNumber, failNumber
let j = 0, k = 0, z = 0;
for (k = 0; k < sectors.length; k++) {
var uid = sectors[k].getUid();
z = 0;
passNumber[k] = 0;
failNumber[k] = 0;
stackeverynum[k] = 0;
for (i = 0; i < output.list.length; i++) {
if (uid === getSectorId(output.list[i].spotId)) {
passNumber[k] = output.list[i].passNum + passNumber[j];
failNumber[k] = output.list[i].failNum + failNumber[j];
stackeverynum[k] = output.list[i].due + stackeverynum[j];
z++;
}
}
if (failNumber[k] + passNumber[k] == 0) {
failrate[k] = 0;
} else {
failrate[k] = failNumber[k] / (failNumber[k] + passNumber[k]) * 100;
}
// z is the number of data in one sector
}
}
})();
this.NameLoader = (function(){
this.onNameRetrieved = function (obj, sta) {
var factory = first_parse(this, obj);
var i, j, t;
console.log(" factory : ");
console.log(factory);
flowPlace = factory.list[0].flowPlace;
flowName = factory.list[0].flowName;
$("#flow_title").html(flowPlace + "-" + flowName + " 度彼科技");
document.title = flowPlace + " " + flowName + " | 流水线管理 | 度彼科技";
};
this.load = function(){
get_data("fcFlow/list?flowId=" + flowId, onNameRetrieved);
};
})();
this.mainLoopFunc = function () {
get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, realtime_success);
HistoryData.update();
};
this.Action = (function () {
this.clearDataOfDeviceId = function (handId) {
executed = false;
directCount = -1;
finished = true;
var hand = handId;
var hd = 0;
if (hand.length > 0) {
hd = parseInt(hand);
}
get_data("endpoint/clearBoard?flowId=" + flowId + "&handheldId=" + hd, clearSuccess);
};
this.doStopSchedule = function () {
get_data("fcWorkSchedule/stopSchedule?userId=" + userId + "&scheduleId=" + scheduleId, UI.showStopSuccess);
};
this.confirmStopSchedule = function () {
var out = confirm("真的要下班吗?");
if (out == true) {
doStopSchedule();
} else {
}
};
})();
this.UI = (function () {
this.showClearPanel = function () {
$("#clearModal").modal('show');
};
this.showStopSuccess = function (obj, sta) {
send_alert("下班操作成功! 点击这里返回控制主页 ");
};
})();
this.HistoryData = (function (){
this.update = function () {
// 请注意type必须在结尾
get_data("fcBiFlowDaily/list?flowId=" + flowId + "&type=1", history_success);
};
this.loadHistroyOnce = function (nnm) {
// 请注意type必须在结尾
get_data(HistoryBaseURL + "&type=" + nnm, history_success);
};
this.loadMultiHistory = function(){
for (i = 1; i <= 3; i++) loadHistroyOnce(i);
};
this.add_success = function(obj, sta) {
var history1 = first_parse(this, obj);
var i, j;
console.log(" history1 : ");
console.log(history1);
hispass[t] = 0;
hisfail[t] = 0;
hisstack[t] = 0;
hisrate[t] = 0;
var lengthnum = history1.length - 1;
for (i = lengthnum; i < history1.length; i++) {
hispass[t] = history1[i].passNum + hispass[t];
hisfail[t] = history1[i].failNum + hisfail[t];
hisstack[t] = history1[i].avgDue + hisstack[t];
}
if (hispass[t] + hisfail[t] == 0) {
hisrate[t] = 0;
}
t++;
}
})();
function realtime_success(obj, sta) {
var output = first_parse(this, obj);
//在这里排序 spo\
console.log(" output : ");
console.log(output);
var i, j, k, z;
failnum = 0;
var x = 0;
var worksum = [];
var hhp = 0, hhf = 0, hhs = 0;
if (output.list.length > 0) {
sectorID[0] = getSectorId(output.list[0].spotId);
passNumber[0] = 0;
failNumber[0] = 0;
stackeverynum[0] = 0;
z = 0;
for (i = 1; i < output.list.length; i++) {
var thisUid = getSectorId(output.list[i].spotId);
x = 0;
for (j = 0; j < sectorID.length; j++) {
if (sectorID[j] === thisUid) {
x = 1;
break;
}
}
if (x === 0) {
sectorID.push(thisUid);
}
}
j = 0;
for (k = 0; k < sectorID.length; k++) {
var uid = sectorID[k];
z = 0;
passNumber[k] = 0;
failNumber[k] = 0;
stackeverynum[k] = 0;
for (i = 0; i < output.list.length; i++) {
if (uid === getSectorId(output.list[i].spotId)) {
passNumber[k] = output.list[i].passNum + passNumber[k];
failNumber[k] = output.list[i].failNum + failNumber[k];
stackeverynum[k] = output.list[i].due + stackeverynum[k];
z++;
}
}
failrate[k] = get_factor(passNumber[k], failNumber[k]);
}
output.list.forEach(function (val, fid, arr) {
hhp += val.passNum;
hhf += val.failNum;
hhs += val.due;
})
}
schedulepass = hhp;
schedulefail = hhf;
if (output.list.length > 0) {
schedulestack = hhs / output.list.length;
} else {
schedulestack = 0;
}
update_all_history();
updateChart();
};
})();
var ClearDataControl = (function () {
this.finished = true;
this.executed = false;
this.directCount = -1;
this.Action = (function () {
})();
this.clearSuccess = function (obj, sta) {
console.warn("------- 手持设备清空 ----------");
console.warn(this);
send_alert("发送清空请求成功, 正在等待采集端进行处理...");
ClearDataControl.finished = false;
setTimeout(resultVerifyTimeout, 8000);
setTimeout(getVerify, 300);
}
this.getVerify = function () {
if (ClearDataControl.finished) return;
get_data("endpoint/heartbeat?flowId=" + flowId, onVerifyResult);
setTimeout(getVerify, 100);
};
this.onVerifyResult = function (obj, sta) {
var parsed = {};
if (typeof(obj) === "string") {
parsed = JSON.parse(obj);
} else {
parsed = obj;
}
if (typeof(parsed) === "object") {
if (parsed.ret === "10000") {
//ok
if (parsed.model == null || parsed.model === undefined) {
executed = true;
finished = true;
} else if (typeof(obj.model) === "object") {
// 没有拿到,继续
if (obj.model.list != null && obj.model.list.length > 0) {
var direct = obj.model.list[0];
if (direct.eventType + "" !== "500") {
// OK
executed = true;
finished = true;
} else if (direct.arg2 + "" !== "" + $("#handInput").val()) {
// OK
executed = true;
finished = true;
} else {
directCount = direct.counter;
}
}
}
}
}
}
this.resultVerifyTimeout = function () {
finished = true;
if (executed) {
// 执行成功
} else {
if (directCount >= 0) {
get_data("endpoint/ack?counter=" + directCount, function () {
console.log("撤销操作成功");
console.log(this);
});
directCount = -1;
send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
} else {
send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
}
}
}
})();
$(document).ready(function(){
});
var RealTimeCharts = (function() {
var timeday = ["今日", "昨日", "本周", "本月"];
if (flowId == null || scheduleId == null) {
send_alert("出错啦!请检查参数完整性");
}
function page_document_load() {
get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, onFirstTimeSuccess);
}
var compAxis = {
categories: namedata,
crosshair: true,
title: {
text: '工位',
style: {
fontSize: '1.5em'
}
},
labels: {
style: {
fontSize: '1.5em'
}
}
};
var getSeperateArrays = function (sectorLoadData){
this.data = [];
this.len = sectorLoadData.len();
this.stackmax = 0;
this.failmax = 0;
this.passmax = 0;
this.failratemax = 0;
this.ratedata = [];
this.passdata = [];
this.faildata = [];
for (i = 0; i < len; i++) {
var one = sectorLoadData.getRaw(i);
if (stackmax < one[i].getVal("stack")) {
stackmax = one[i].getVal("stack")
}
if (failmax < one[i].getVal("failNum")) {
failmax = one[i].getVal("failNum");
}
if (failratemax < one[i].getVal("failRate")) {
failratemax = one[i].getVal("failRate");
}
if (passmax < one[i].getVal("passNum")) {
passmax = one[i].getVal("passNum");
}
data.push(one[i].getVal("stack"));
this.ratedata.push(Math.floor(one[i].getVal("failRate")));
this.passdata.push(one[i].getVal("passNum"));
this.faildata.push(one[i].getVal("failNum"));
}
};
this.dataArrays = null;
function showChart(sectorLoadData) {
dataArrays = new getSeperateArrays(sectorLoadData);
failratemax = Math.max(failratemax, 5);
stackmax = Math.max(stackmax, 5);
failmax = Math.max(failmax, 5);
passmax = Math.max(passmax, failmax, stackmax);
stackAndFailChart = Highcharts.chart('graph-1', {
chart: {
zoomType: 'xy',
//height: (4 / 16 * 100) + '%' // 16:9 ratio
},
title: {text: '各工位今日产能'},
credits: {enabled: false},
exporting: {enabled: false},
xAxis: [compAxis],
yAxis: [{
labels: {
format: '{value}',
style: {
color: "#ffffff",
fontSize: '1.5em'
}
},
min: 0,
max: passmax * 1.5,
title: {
text: '数量',
style: {
color: '#ffffff',
fontSize: '1em'
},
rotation: 270,
}
},],
tooltip: {shared: true},
legend: {
layout: 'vertical',
align: 'right',
x: 0,
verticalAlign: 'top',
y: 0,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
series: [{
name: '良品数',
type: 'column',
data: passdata,
}, {
name: '不良品数',
type: 'column',
data: faildata,
},
{
name: '堆积数',
type: 'column',
data: data,
}]
});
FailChart = Highcharts.chart('graph-2', {
chart: {
//height: (4 / 16 * 100) + '%' // 16:9 ratio
},
title: {
text: '各工位今日不良率'
},
credits: {
enabled: false // 禁用版权信息
},
exporting: {
enabled: false
},
xAxis: [compAxis],
yAxis: [{ // Secondary yAxis
title: {
text: '不良率',
style: {
color: '#ffffff',
fontSize: '1em'
}
},
min: 0,
max: 1.5 * failratemax,
labels: {
formatter: function () {
return Math.floor(this.value) + "%";
},
style: {
color: '#ffffff',
fontSize: '20px'
},
rotation: 270,
},
}],
tooltip: {
shared: true
},
legend: {
layout: 'vertical',
align: 'right',
x: 0,
verticalAlign: 'top',
y: 0,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
series: [{
name: '不良率',
type: 'spline',
data: ratedata,
color: 'red',
tooltip: {
valueSuffix: '%'
}
}]
});
}
function updateChart() {
var data = [];
var ratedata = [];
var stackmax = 0;
var failmax = 0;
var passdata = [];
var faildata = [];
var passmax = 0;
var failratemax = 0;
for (i = 0; i < passNumber.length; i++) {
if (stackmax < stackeverynum[i]) {
stackmax = stackeverynum[i];
}
if (failmax < failNumber[i]) {
failmax = failNumber[i];
}
if (failratemax < failrate[i]) {
failratemax = failrate[i];
}
if (passmax < passNumber[i]) {
passmax = passNumber[i];
}
data.push(stackeverynum[i]);
ratedata.push(Math.floor(failrate[i]));
passdata.push(passNumber[i]);
faildata.push(failNumber[i])
}
failratemax = Math.max(failratemax, 5);
stackmax = Math.max(stackmax, 5);
failmax = Math.max(failmax, 5);
passmax = Math.max(passmax, failmax, stackmax);
// https://api.hcharts.cn/highcharts#Series.addPoint;
stackAndFailChart.series[0].setData(passdata);
stackAndFailChart.series[1].setData(faildata);
stackAndFailChart.series[2].setData(data);
FailChart.series[0].setData(ratedata);
if (failratemax > FailChart.yAxis[0].getExtremes().max * 1.3 || failratemax < FailChart.yAxis[0].getExtremes().max * 0.5) {
FailChart.yAxis[0].setExtremes(0, failratemax * 1.5);
}
if (passmax > stackAndFailChart.yAxis[0].getExtremes().max * 1.3 || passmax < stackAndFailChart.yAxis[0].getExtremes().max * 0.5) {
stackAndFailChart.yAxis[0].setExtremes(0, passmax * 1.5);
}
showHistoryData();
showRedRanking();
showBlackRanking();
var secNames = [];
sectorID.forEach(function (val) {
secNames.push(getSectorName(val));
});
if (JSON.stringify(secNames) !== lastTimeSecNames) {
lastTimeSecNames = JSON.stringify(secNames);
FailChart.xAxis[0].setCategories(secNames);
stackAndFailChart.xAxis[0].setCategories(secNames);
}
}
var lastTimeSecNames = "";
var stackAndFailChart = null;
var FailChart = null;
})();