dapingmu-display.js 5.5 KB

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