dapingmu-display.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. var timeday = new Array("今日", "昨日", "本周", "本月");
  2. var i = 0, j = 0;
  3. function showChart() {
  4. var stackdata = [];
  5. var passdata = [];
  6. var faildata = [];
  7. var ratedata = [];
  8. var failmax = 0;
  9. var passmax = 0;
  10. var iddata = [];
  11. var summax = 0;
  12. var stackmax = 0;
  13. var ratemax = 0;
  14. for (i = 0; i < flowIds.length; i++) {
  15. passdata.push(passNumber[i]);
  16. faildata.push(failNumber[i]);
  17. stackdata.push(stackeverynum[i]);
  18. ratedata.push(failrate[i]);
  19. iddata.push(flowIds[i]);
  20. if (ratemax < ratedata[i]) {
  21. ratemax = ratedata[i];
  22. }
  23. if (passmax < passNumber[i]) {
  24. passmax = passNumber[i];
  25. }
  26. if (failmax < passNumber[i]) {
  27. failmax = passNumber[i];
  28. }
  29. if (stackmax < passNumber[i]) {
  30. stackmax = passNumber[i];
  31. }
  32. }
  33. if (passmax < failmax) {
  34. passmax = failmax
  35. }
  36. if (passmax < stackmax) {
  37. passmax = stackmax;
  38. }
  39. var uaxv = {
  40. crosshair: true,
  41. labels: {
  42. style: {
  43. fontSize: '1.5em'
  44. }
  45. },
  46. categories: iddata,
  47. };
  48. showHistoryData();
  49. showRedRanking();
  50. stackAndFailChart = Highcharts.chart('graph-1', {
  51. chart: {
  52. zoomType: 'xy',
  53. //height: (4 / 16 * 100) + '%' // 16:9 ratio
  54. },
  55. title: {text: '各产线今日产能'},
  56. credits: {enabled: false},
  57. exporting: {enabled: false},
  58. xAxis: [uaxv],
  59. yAxis: [{
  60. labels: {
  61. format: '{value}',
  62. style: {
  63. color: Highcharts.getOptions().colors[0],
  64. fontSize: '1.5em'
  65. }
  66. },
  67. min: 0,
  68. max: passmax * 1.5,
  69. title: {
  70. style: {
  71. color: Highcharts.getOptions().colors[0],
  72. fontSize: '1em'
  73. },
  74. rotation: 270,
  75. }
  76. },],
  77. tooltip: {shared: true},
  78. legend: {
  79. layout: 'vertical',
  80. align: 'right',
  81. x: -100,
  82. verticalAlign: 'top',
  83. y: 0,
  84. floating: true,
  85. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  86. },
  87. series: [{
  88. name: '良品数',
  89. type: 'column',
  90. data: passdata,
  91. }, {
  92. name: '不良品数',
  93. type: 'column',
  94. data: faildata,
  95. },
  96. {
  97. name: '堆积数',
  98. type: 'column',
  99. data: stackdata,
  100. }]
  101. });
  102. FailChart = Highcharts.chart('graph-2', {
  103. chart: {
  104. //height: (4 / 16 * 100) + '%' // 16:9 ratio
  105. },
  106. title: {
  107. text: '不良率'
  108. },
  109. credits: {
  110. enabled: false // 禁用版权信息
  111. },
  112. exporting: {
  113. enabled: false
  114. },
  115. xAxis: [uaxv],
  116. yAxis: [{ // Secondary yAxis
  117. title: {
  118. text: '不良率',
  119. style: {
  120. color: 'red',
  121. fontSize: '1em'
  122. },
  123. rotation: 270,
  124. },
  125. min: 0,
  126. max: 1.5 * ratemax,
  127. labels: {
  128. formatter: function () {
  129. return Math.floor(this.value) + "%";
  130. },
  131. style: {
  132. color: 'red',
  133. fontSize: '20px'
  134. }
  135. },
  136. }],
  137. tooltip: {
  138. shared: true
  139. },
  140. legend: {
  141. layout: 'vertical',
  142. align: 'right',
  143. x: -120,
  144. verticalAlign: 'top',
  145. y: 0,
  146. floating: true,
  147. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  148. },
  149. series: [{
  150. name: '不良率',
  151. type: 'spline',
  152. data: ratedata,
  153. color: 'red',
  154. tooltip: {
  155. valueSuffix: '%'
  156. }
  157. }]
  158. });
  159. }
  160. function updateChart() {
  161. var stackdata = [];
  162. var passdata = [];
  163. var faildata = [];
  164. var ratedata = [];
  165. var failmax = 0;
  166. var passmax = 0;
  167. var iddata = [];
  168. var summax = 0;
  169. var stackmax = 0;
  170. var ratemax = 0;
  171. for (i = 0; i < passNumber.length; i++) {
  172. passdata.push(passNumber[i]);
  173. faildata.push(failNumber[i]);
  174. stackdata.push(stackeverynum[i]);
  175. ratedata.push(failrate[i]);
  176. iddata.push(flowIds[i]);
  177. if (ratemax < ratedata[i]) {
  178. ratemax = ratedata[i];
  179. }
  180. if (passmax < passNumber[i]) {
  181. passmax = passNumber[i];
  182. }
  183. if (failmax < passNumber[i]) {
  184. failmax = passNumber[i];
  185. }
  186. if (stackmax < passNumber[i]) {
  187. stackmax = passNumber[i];
  188. }
  189. }
  190. if (passmax < failmax) {
  191. passmax = failmax
  192. }
  193. if (passmax < stackmax) {
  194. passmax = stackmax;
  195. }
  196. // https://api.hcharts.cn/highcharts#Series.addPoint;
  197. stackAndFailChart.series[0].setData(passdata);
  198. stackAndFailChart.series[1].setData(faildata);
  199. stackAndFailChart.series[2].setData(stackdata);
  200. FailChart.series[0].setData(ratedata);
  201. showHistoryData();
  202. showRedRanking();
  203. showBlackRanking();
  204. }
  205. var stackAndFailChart = null;
  206. var FailChart = null;