lazhang-display.js 6.5 KB

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