dapingmu-display.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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.gestOptions().colors[0],
  73. fontSize: '1em'
  74. },
  75. rotation: 270,
  76. }
  77. },],
  78. tooltip: {shared: true},
  79. legend: {
  80. layout: 'vertical',
  81. align: 'right',
  82. x: -100,
  83. verticalAlign: 'top',
  84. y: 0,
  85. floating: true,
  86. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  87. },
  88. series: [{
  89. name: '良品数',
  90. type: 'column',
  91. data: passdata,
  92. }, {
  93. name: '不良品数',
  94. type: 'column',
  95. data: faildata,
  96. },
  97. {
  98. name: '堆积数',
  99. type: 'column',
  100. data: stackdata,
  101. }]
  102. });
  103. FailChart = Highcharts.chart('graph-2', {
  104. chart: {
  105. //height: (4 / 16 * 100) + '%' // 16:9 ratio
  106. },
  107. title: {
  108. text: '不良率'
  109. },
  110. credits: {
  111. enabled: false // 禁用版权信息
  112. },
  113. exporting: {
  114. enabled: false
  115. },
  116. xAxis: [uaxv],
  117. yAxis: [{ // Secondary yAxis
  118. title: {
  119. text: '不良率',
  120. style: {
  121. color: 'red',
  122. fontSize: '1em'
  123. },
  124. rotation: 270,
  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. }
  206. var stackAndFailChart = null;
  207. var FailChart = null;