lazhang-display.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. showEachSpot();
  51. showEachSpot1();
  52. showEachSpot2();
  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. }
  83. },],
  84. tooltip: {shared: true},
  85. legend: {
  86. layout: 'vertical',
  87. align: 'right',
  88. x: 0,
  89. verticalAlign: 'top',
  90. y: 0,
  91. floating: true,
  92. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  93. },
  94. series: [{
  95. name: '良品数',
  96. type: 'column',
  97. data: passdata,
  98. }, {
  99. name: '不良品数',
  100. type: 'column',
  101. data: faildata,
  102. },
  103. {
  104. name: '堆积数',
  105. type: 'column',
  106. data: data,
  107. }]
  108. });
  109. FailChart = Highcharts.chart('graph-2', {
  110. chart: {
  111. //height: (4 / 16 * 100) + '%' // 16:9 ratio
  112. },
  113. title: {
  114. text: '各工位今日不良率'
  115. },
  116. credits: {
  117. enabled: false // 禁用版权信息
  118. },
  119. exporting: {
  120. enabled: false
  121. },
  122. xAxis: [compAxis],
  123. yAxis: [{ // Secondary yAxis
  124. title: {
  125. text: '不良率',
  126. style: {
  127. color: '#ffffff',
  128. fontSize: '1em'
  129. }
  130. },
  131. min: 0,
  132. max: 1.5 * failratemax,
  133. labels: {
  134. formatter: function () {
  135. return Math.floor(this.value) + "%";
  136. },
  137. style: {
  138. color: '#ffffff',
  139. fontSize: '20px'
  140. }
  141. },
  142. }],
  143. tooltip: {
  144. shared: true
  145. },
  146. legend: {
  147. layout: 'vertical',
  148. align: 'right',
  149. x: 0,
  150. verticalAlign: 'top',
  151. y: 0,
  152. floating: true,
  153. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  154. },
  155. series: [{
  156. name: '不良率',
  157. type: 'spline',
  158. data: ratedata,
  159. color: 'red',
  160. tooltip: {
  161. valueSuffix: '%'
  162. }
  163. }]
  164. });
  165. }
  166. function updateChart() {
  167. var data = [];
  168. var ratedata = [];
  169. var stackmax = 0;
  170. var failmax = 0;
  171. var passdata = [];
  172. var faildata = [];
  173. var passmax = 0;
  174. var failratemax=0;
  175. for (i = 0; i < passNumber.length; i++) {
  176. if (stackmax < stackeverynum[i]) {
  177. stackmax = stackeverynum[i];
  178. }
  179. if (failmax < failNumber[i]) {
  180. failmax = failNumber[i];
  181. }
  182. if (failratemax < failrate[i]) {
  183. failratemax= failrate[i];
  184. }
  185. if (passmax < passNumber[i]) {
  186. passmax = passNumber[i];
  187. }
  188. data.push(stackeverynum[i]);
  189. ratedata.push(Math.floor(failrate[i]));
  190. passdata.push(passNumber[i]);
  191. faildata.push(failNumber[i])
  192. }
  193. failratemax = Math.max(failratemax, 5);
  194. stackmax = Math.max(stackmax, 5);
  195. failmax = Math.max(failmax, 5);
  196. passmax = Math.max(passmax,failmax,stackmax);
  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(data);
  201. FailChart.series[0].setData(ratedata);
  202. if (failratemax > FailChart.yAxis[0].getExtremes().max * 1.3 || failratemax < FailChart.yAxis[0].getExtremes().max * 0.5) {
  203. FailChart.yAxis[0].setExtremes(0, failratemax * 1.5);
  204. }
  205. if (passmax > stackAndFailChart.yAxis[0].getExtremes().max * 1.3 || passmax < stackAndFailChart.yAxis[0].getExtremes().max * 0.5) {
  206. stackAndFailChart.yAxis[0].setExtremes(0, passmax * 1.5);
  207. }
  208. showEachSpot();
  209. showEachSpot1();
  210. showEachSpot2();
  211. var secNames = [];
  212. sectorID.forEach(function(val){ secNames.push(getSectorName(val)); });
  213. if(JSON.stringify(secNames) !== lastTimeSecNames){
  214. lastTimeSecNames = JSON.stringify(secNames);
  215. FailChart.xAxis[0].setCategories(secNames);
  216. stackAndFailChart.xAxis[0].setCategories(secNames);
  217. }
  218. }
  219. var lastTimeSecNames = "";
  220. var stackAndFailChart = null;
  221. var FailChart = null;