123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- var timeday = new Array("今日", "昨日", "本周", "本月");
- var i = 0, j = 0;
- function showChart() {
- var stackdata = [];
- var passdata = [];
- var faildata = [];
- var ratedata = [];
- var failmax = 0;
- var passmax = 0;
- var iddata = [];
- var summax = 0;
- var stackmax = 0;
- var ratemax = 0;
- for (i = 0; i < flowIds.length; i++) {
- passdata.push(passNumber[i]);
- faildata.push(failNumber[i]);
- stackdata.push(stackeverynum[i]);
- ratedata.push(failrate[i]);
- iddata.push(flowIds[i]);
- if (ratemax < ratedata[i]) {
- ratemax = ratedata[i];
- }
- if (passmax < passNumber[i]) {
- passmax = passNumber[i];
- }
- if (failmax < passNumber[i]) {
- failmax = passNumber[i];
- }
- if (stackmax < passNumber[i]) {
- stackmax = passNumber[i];
- }
- }
- if (passmax < failmax) {
- passmax = failmax
- }
- if (passmax < stackmax) {
- passmax = stackmax;
- }
- var uaxv = {
- crosshair: true,
- labels: {
- style: {
- fontSize: '1.5em'
- }
- },
- categories: iddata,
- };
- showEachSpot();
- showEachSpot1();
- showEachSpot2();
- stackAndFailChart = Highcharts.chart('graph-1', {
- chart: {
- zoomType: 'xy',
- //height: (4 / 16 * 100) + '%' // 16:9 ratio
- },
- title: {text: '各产线今日产能'},
- credits: {enabled: false},
- exporting: {enabled: false},
- xAxis: [uaxv],
- yAxis: [{
- labels: {
- format: '{value}',
- style: {
- color: Highcharts.getOptions().colors[0],
- fontSize: '1.5em'
- }
- },
- min: 0,
- max: passmax * 1.5,
- title: {
- style: {
- color: Highcharts.getOptions().colors[0],
- fontSize: '1em'
- }
- }
- },],
- tooltip: {shared: true},
- legend: {
- layout: 'vertical',
- align: 'right',
- x: -100,
- 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: stackdata,
- }]
- });
- FailChart = Highcharts.chart('graph-2', {
- chart: {
- //height: (4 / 16 * 100) + '%' // 16:9 ratio
- },
- title: {
- text: '不良率'
- },
- credits: {
- enabled: false // 禁用版权信息
- },
- exporting: {
- enabled: false
- },
- xAxis: [uaxv],
- yAxis: [{ // Secondary yAxis
- title: {
- text: '不良率',
- style: {
- color: 'red',
- fontSize: '1em'
- }
- },
- min: 0,
- max: 1.5 * ratemax,
- labels: {
- formatter: function () {
- return Math.floor(this.value) + "%";
- },
- style: {
- color: 'red',
- fontSize: '20px'
- }
- },
- }],
- tooltip: {
- shared: true
- },
- legend: {
- layout: 'vertical',
- align: 'right',
- x: -120,
- 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 stackdata = [];
- var passdata = [];
- var faildata = [];
- var ratedata = [];
- var failmax = 0;
- var passmax = 0;
- var iddata = [];
- var summax = 0;
- var stackmax = 0;
- var ratemax = 0;
- for (i = 0; i < passNumber.length; i++) {
- passdata.push(passNumber[i]);
- faildata.push(failNumber[i]);
- stackdata.push(stackeverynum[i]);
- ratedata.push(failrate[i]);
- iddata.push(flowIds[i]);
- if (ratemax < ratedata[i]) {
- ratemax = ratedata[i];
- }
- if (passmax < passNumber[i]) {
- passmax = passNumber[i];
- }
- if (failmax < passNumber[i]) {
- failmax = passNumber[i];
- }
- if (stackmax < passNumber[i]) {
- stackmax = passNumber[i];
- }
- }
- if (passmax < failmax) {
- passmax = failmax
- }
- if (passmax < stackmax) {
- passmax = stackmax;
- }
- // https://api.hcharts.cn/highcharts#Series.addPoint;
- stackAndFailChart.series[0].setData(passdata);
- stackAndFailChart.series[1].setData(faildata);
- stackAndFailChart.series[2].setData(stackdata);
- FailChart.series[0].setData(ratedata);
- showEachSpot();
- showEachSpot1();
- showEachSpot2();
- }
- var stackAndFailChart = null;
- var FailChart = null;
|