dapingmu-display.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. stackAndFailChart = Highcharts.chart('graph-1', {
  52. chart: {
  53. zoomType: 'xy',
  54. //height: (4 / 16 * 100) + '%' // 16:9 ratio
  55. },
  56. title: {text: '各产线今日产能'},
  57. credits: {enabled: false},
  58. exporting: {enabled: false},
  59. xAxis: [uaxv],
  60. yAxis: [{
  61. labels: {
  62. format: '{value}',
  63. style: {
  64. color: Highcharts.getOptions().colors[0],
  65. fontSize: '1.5em'
  66. }
  67. },
  68. min: 0,
  69. max: passmax * 1.5,
  70. title: {
  71. style: {
  72. color: Highcharts.getOptions().colors[0],
  73. fontSize: '1em'
  74. }
  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. },
  124. min: 0,
  125. max: 1.5 * ratemax,
  126. labels: {
  127. formatter: function () {
  128. return Math.floor(this.value) + "%";
  129. },
  130. style: {
  131. color: 'red',
  132. fontSize: '20px'
  133. }
  134. },
  135. }],
  136. tooltip: {
  137. shared: true
  138. },
  139. legend: {
  140. layout: 'vertical',
  141. align: 'right',
  142. x: -120,
  143. verticalAlign: 'top',
  144. y: 0,
  145. floating: true,
  146. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  147. },
  148. series: [{
  149. name: '不良率',
  150. type: 'spline',
  151. data: ratedata,
  152. color: 'red',
  153. tooltip: {
  154. valueSuffix: '%'
  155. }
  156. }]
  157. });
  158. }
  159. function updateChart() {
  160. var stackdata = [];
  161. var passdata = [];
  162. var faildata = [];
  163. var ratedata = [];
  164. var failmax = 0;
  165. var passmax = 0;
  166. var iddata = [];
  167. var summax = 0;
  168. var stackmax = 0;
  169. var ratemax = 0;
  170. for (i = 0; i < passNumber.length; i++) {
  171. passdata.push(passNumber[i]);
  172. faildata.push(failNumber[i]);
  173. stackdata.push(stackeverynum[i]);
  174. ratedata.push(failrate[i]);
  175. iddata.push(flowIds[i]);
  176. if (ratemax < ratedata[i]) {
  177. ratemax = ratedata[i];
  178. }
  179. if (passmax < passNumber[i]) {
  180. passmax = passNumber[i];
  181. }
  182. if (failmax < passNumber[i]) {
  183. failmax = passNumber[i];
  184. }
  185. if (stackmax < passNumber[i]) {
  186. stackmax = passNumber[i];
  187. }
  188. }
  189. if (passmax < failmax) {
  190. passmax = failmax
  191. }
  192. if (passmax < stackmax) {
  193. passmax = stackmax;
  194. }
  195. // https://api.hcharts.cn/highcharts#Series.addPoint;
  196. stackAndFailChart.series[0].setData(passdata);
  197. stackAndFailChart.series[1].setData(faildata);
  198. stackAndFailChart.series[2].setData(stackdata);
  199. FailChart.series[0].setData(ratedata);
  200. showEachSpot();
  201. showEachSpot1();
  202. showEachSpot2();
  203. }
  204. var stackAndFailChart = null;
  205. var FailChart = null;