tower.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. console.log(1);
  2. var xhr = new XMLHttpRequest();
  3. var url = "tower/org";
  4. obj = "";
  5. xhr.open("GET", url);
  6. xhr.onload = function () {
  7. obj = JSON.parse(xhr.responseText);
  8. //insertHTML();
  9. start();
  10. onChangeColumn1();
  11. onChangeColumn2();
  12. onChangeColumn3();
  13. click_button();
  14. };
  15. xhr.send();
  16. function insertHTML(data) {
  17. var tower_select = document.getElementById('tower');
  18. //aria.innerHTML=data[0].tower_name;
  19. var inner = '';
  20. for (var i = 0; i < data.length; i++) {
  21. if (i >= 5) {
  22. inner = inner + '<button type="button" style="padding:15px 30px; background:#fff; color:#002e86; border: 1px solid #002E86; border-radius: 10px; font-size:18px;" class="tower-btn me-3" onclick="tower_info(\'' + data[0].tower_name + '\');">' + data[i].tower_name + '</button>';
  23. }
  24. else {
  25. inner = inner + '<button type="button" style="padding:15px 30px; background:#fff; color:#002e86; border: 1px solid #002E86; border-radius: 10px; font-size:18px;" class="tower-btn me-3" onclick="tower_info(\'' + data[i].tower_name + '\');">' + data[i].tower_name + '</button>';
  26. }
  27. console.log(inner);
  28. }
  29. tower_select.innerHTML = inner;
  30. }
  31. obj2 = "";
  32. function click_button() {
  33. //alert("click");
  34. companySelect = document.getElementById("company-list");
  35. factorySelect = document.getElementById("factory-list");
  36. departmentSelect = document.getElementById("department-list");
  37. towerGroupSelect = document.getElementById("towerGroup-list");
  38. if (companySelect.value != 0 && factorySelect.value != 0 && departmentSelect.value != 0 && towerGroupSelect.value != 0) {
  39. var url2 = "tower/?company=" + companySelect.value + "&factory=" + factorySelect.value + "&department=" + departmentSelect.value + "&towerGroup=" + towerGroupSelect.value;
  40. var xhr2 = new XMLHttpRequest();
  41. xhr2.open("GET", url2);
  42. xhr2.onload = function () {
  43. obj2 = JSON.parse(xhr2.responseText);
  44. insertHTML(obj2);
  45. console.log(obj2);
  46. tower_info(obj2[0].tower_name);
  47. };
  48. xhr2.send();
  49. }
  50. }
  51. function tower_info(tower_str) {
  52. $(document).on("click", ".tower-btn", function (event) {
  53. $(this).addClass("tower-active");
  54. $(".tower-active").siblings().removeClass('tower-active');
  55. });
  56. tower = tower_str;
  57. console.log(tower);
  58. inner = "";
  59. for (var i = 0; i < obj2.length; i++) {
  60. if (obj2[i].tower_name == tower) {
  61. // inner = '<p> DCS </P> '+
  62. // '<p> 入水溫度 = '+ obj2[i].tower_data.DCS.hotTemp + ' </P> ' +
  63. // '<p> 出水溫度 = '+ obj2[i].tower_data.DCS.coldTemp + ' </P> ' +
  64. // '<p> 水流量 = '+ obj2[i].tower_data.DCS.waterFlow + ' </P> ' +
  65. // '<p> 風扇馬達電流 = '+ obj2[i].tower_data.DCS.fanMotorCur + ' </P> ' +
  66. // '<p> 風扇馬達轉速頻率 = '+ obj2[i].tower_data.DCS.fanMotorSpeedFreq + ' </P><br> ' +
  67. // '<p> 風扇震動 </P> '+
  68. // '<p> 馬達震動 = '+ obj2[i].tower_data.Moter.ch01.Vrms + ' </P> ' +
  69. // '<p> 減速機震動 = '+ obj2[i].tower_data.Fan.reducer + ' </P> ' +
  70. // '<p> 靜壓機 = '+ obj2[i].tower_data.Fan.staticPressure + ' </P> ' +
  71. // '<p> 水流量 = '+ obj2[i].tower_data.Fan.waterFlow + ' </P> ' +
  72. // '<p> 濕求溫度 = '+ obj2[i].tower_data.Fan.wetTemp + ' </P> ' +
  73. // '<p> 水冷槽溫度1 = '+ obj2[i].tower_data.Fan.coldTempData1 + ' </P> ' +
  74. // '<p> 水冷槽溫度2 = '+ obj2[i].tower_data.Fan.coldTempData2 + ' </P><br> ' +
  75. // '<p> 馬達震動 </P> '+
  76. // '<p> ch001,通道1'+ obj2[i].tower_data.Moter.ch01.Vrms + ',' + obj2[i].tower_data.Moter.ch01.CV+' </P> ' +
  77. // '<p> ch002,通道2'+ obj2[i].tower_data.Moter.ch02.Vrms + ',' + obj2[i].tower_data.Moter.ch02.CV+' </P> '
  78. // ;
  79. inner = '<div style="padding:15px;"><h1 style="color:#002e86">中控室DSC訊號</h1>\
  80. <div class="row px-0 mx-0">\
  81. <div class="card col-lg-2">\
  82. <p class="data-title fw-bold pt-3">入水溫度</p>\
  83. <div>\
  84. <h2 class="data-content text-center mt-3 pb-3">'+ obj2[i].tower_data.DCS.hotTemp + '<span style="font-size:20px;">&ensp;°C</span></h2>\
  85. </div>\
  86. </div>\
  87. <div class="card col-lg-2">\
  88. <p class="data-title fw-bold pt-3">出水溫度</p>\
  89. <div>\
  90. <h2 class="data-content text-center mt-3 pb-3">'+ obj2[i].tower_data.DCS.coldTemp + '<span style="font-size:20px;">&ensp;°C</span></h2>\
  91. </div>\
  92. </div>\
  93. <div class="card col-lg-2">\
  94. <p class="data-title fw-bold pt-3">水流量</p>\
  95. <div>\
  96. <h2 class="data-content text-center mt-3 pb-3">'+ obj2[i].tower_data.DCS.waterFlow + '<span style="font-size:20px;">&ensp;M³/H</span></h2>\
  97. </div>\
  98. </div>\
  99. <div class="card col-lg-2">\
  100. <p class="data-title fw-bold pt-3">風扇馬達電流</p>\
  101. <div>\
  102. <h2 class="data-content text-center mt-3 pb-3">'+ obj2[i].tower_data.DCS.fanMotorCur + '<span style="font-size:20px;">&ensp;A</span></h2>\
  103. </div>\
  104. </div>\
  105. <div class="card col-lg-2">\
  106. <p class="data-title fw-bold pt-3">風扇馬達轉速頻率</p>\
  107. <div>\
  108. <h2 class="data-content text-center mt-3 pb-3">'+ obj2[i].tower_data.DCS.fanMotorSpeedFreq + '<span style="font-size:20px;">&ensp;Hz</span></h2>\
  109. </div>\
  110. </div>\
  111. </div>\
  112. </div>\
  113. <div class="mt-5">\
  114. <div>\
  115. <div class="row px-0 mx-0">\
  116. <div class="col-lg-6">\
  117. <div class="card">\
  118. <h1 style="color:#002e86">風扇震動</h1>\
  119. <div style="padding:15px">\
  120. <table style="font-size: 16px; border-color:#4c6caa; border-top:1px solid #4c6caa;" class="table text-center">\
  121. <thead style="background:#e4f8ff; color:#4c6caa;">\
  122. <tr>\
  123. <th class="border-0" scope="col">數據名稱</th>\
  124. <th class="border-0" scope="col">值</th>\
  125. <th class="border-0" scope="col">單位</th>\
  126. </tr>\
  127. </thead>\
  128. <tbody>\
  129. <tr>\
  130. <td>馬達震動</td>\
  131. <td>'+ obj2[i].tower_data.Moter[0].DataValue + '</td>\
  132. <td>mm/s</td>\
  133. </tr>\
  134. <tr>\
  135. <td>減速機震動</td>\
  136. <td>'+ obj2[i].tower_data.Fan.reducer + '</td>\
  137. <td>mm/s</td>\
  138. </tr>\
  139. <tr>\
  140. <td>靜壓機</td>\
  141. <td>'+ obj2[i].tower_data.Fan.staticPressure + '</td>\
  142. <td>pa</td>\
  143. </tr>\
  144. <tr>\
  145. <td>水流量</td>\
  146. <td>'+ obj2[i].tower_data.Fan.waterFlow + '</td>\
  147. <td>M³/H</td>\
  148. </tr>\
  149. <tr>\
  150. <td>濕求溫度</td>\
  151. <td>'+ obj2[i].tower_data.Fan.wetTemp + '</td>\
  152. <td>°C</td>\
  153. </tr>\
  154. <tr>\
  155. <td>水冷槽溫度1</td>\
  156. <td>'+ obj2[i].tower_data.Fan.coldTempData1 + '</td>\
  157. <td>°C</td>\
  158. </tr>\
  159. <tr>\
  160. <td>水冷槽溫度2</td>\
  161. <td>'+ obj2[i].tower_data.Fan.coldTempData2 + '</td>\
  162. <td>°C</td>\
  163. </tr>\
  164. </tbody>\
  165. </table>\
  166. </div>\
  167. </div>\
  168. </div>\
  169. <div style="margin-top:40px;" class="col-lg-6">\
  170. <div>\
  171. <h1 style="color:#002e86">馬達震動</h1>\
  172. <div class="row px-0 mx-0">\
  173. <div class="card col-lg-5">\
  174. <p class="fw-bold pt-4">ch001,通道1</p>\
  175. <div>\
  176. <p class="text-center pb-4">'+ obj2[i].tower_data.Moter[0].DataValue + ',' + obj2[i].tower_data.Moter[0].CVIndex + '</p>\
  177. </div>\
  178. </div>\
  179. <div class="card col-lg-5">\
  180. <p class="fw-bold pt-4">ch002,通道2</p>\
  181. <div>\
  182. <p class="text-center pb-4">'+ obj2[i].tower_data.Moter[1].DataValue + ',' + obj2[i].tower_data.Moter[1].CVIndex + '</p>\
  183. </div>\
  184. </div>\
  185. <div class="card col-lg-5">\
  186. <p class="fw-bold pt-4">ch003,通道3</p>\
  187. <div>\
  188. <p class="text-center pb-4">'+ obj2[i].tower_data.Moter[2].DataValue + ',' + obj2[i].tower_data.Moter[2].CVIndex + '</p>\
  189. </div>\
  190. </div>\
  191. <div class="card col-lg-5">\
  192. <p class="fw-bold pt-4">ch004,通道4</p>\
  193. <div>\
  194. <p class="text-center pb-4">'+ obj2[i].tower_data.Moter[3].DataValue + ',' + obj2[i].tower_data.Moter[3].CVIndex + '</p>\
  195. </div>\
  196. </div>\
  197. </div>\
  198. </div>\
  199. </div>\
  200. </div>\
  201. </div>\
  202. </div>';
  203. console.log(obj2[i].tower_data.Moter[3].Vrms);
  204. }
  205. }
  206. document.getElementById("tower_info").innerHTML = inner;
  207. console.log(inner);
  208. get_tower_perfrom('dev001');
  209. }
  210. //document就是這html文件。
  211. //getElementById是裡面的方法,參數給"college-list"抓到這id標籤列
  212. function start() {
  213. companySelect = document.getElementById("company-list");
  214. factorySelect = document.getElementById("factory-list");
  215. departmentSelect = document.getElementById("department-list");
  216. towerGroupSelect = document.getElementById("towerGroup-list");
  217. var inner = '';
  218. var company_arr = new Array();
  219. for (var i = 0; i < obj.length; i++) {
  220. if (company_arr.indexOf(obj[i].company) == -1 && obj[i].able == 1) {
  221. inner = inner + '<option value="' + obj[i].company + '">公司' + obj[i].company + '</option>';
  222. company_arr.push(obj[i].company);
  223. }
  224. }
  225. //innerHTML 賦值inner給這element屬性
  226. companySelect.innerHTML = inner;
  227. }
  228. //製造一個字串,以html的語法填入院的陣列
  229. function onChangeColumn1() {
  230. companySelect = document.getElementById("company-list");
  231. factorySelect = document.getElementById("factory-list");
  232. departmentSelect = document.getElementById("department-list");
  233. towerGroupSelect = document.getElementById("towerGroup-list");
  234. factorySelect.innerHTML = '';
  235. let factory_arr = new Array();
  236. let factory_inner = '';
  237. for (var i = 0; i < obj.length; i++) {
  238. if (companySelect.value == obj[i].company) {
  239. if (factory_arr.indexOf(obj[i].factory) == -1 && obj[i].able == 1) {
  240. factory_inner = factory_inner + '<option value="' + obj[i].factory + '">廠區' + obj[i].factory + '</option>';
  241. factory_arr.push(obj[i].factory);
  242. }
  243. }
  244. //alert(companySelect.value);
  245. }
  246. factorySelect.innerHTML = factory_inner;
  247. }
  248. function onChangeColumn2() {
  249. companySelect = document.getElementById("company-list");
  250. factorySelect = document.getElementById("factory-list");
  251. departmentSelect = document.getElementById("department-list");
  252. towerGroupSelect = document.getElementById("towerGroup-list");
  253. departmentSelect.innerHTML = '';
  254. let department_arr = new Array();
  255. let department_inner = '';
  256. for (var i = 0; i < obj.length; i++) {
  257. if (companySelect.value == obj[i].company && factorySelect.value == obj[i].factory) {
  258. if (department_arr.indexOf(obj[i].department) == -1 && obj[i].able == 1) {
  259. department_inner = department_inner + '<option value="' + obj[i].department + '">課' + obj[i].department + '</option>';
  260. department_arr.push(obj[i].department);
  261. }
  262. }
  263. }
  264. document.getElementById("department-list").innerHTML = department_inner;
  265. }
  266. function onChangeColumn3() {
  267. companySelect = document.getElementById("company-list");
  268. factorySelect = document.getElementById("factory-list");
  269. departmentSelect = document.getElementById("department-list");
  270. towerGroupSelect = document.getElementById("towerGroup-list");
  271. towerGroupSelect.innerHTML = '';
  272. let towerGroup_inner = '';
  273. for (var i = 0; i < obj.length; i++) {
  274. if (companySelect.value == obj[i].company && factorySelect.value == obj[i].factory && departmentSelect.value == obj[i].department) {
  275. if (obj[i].able == 1) {
  276. for (var ii = 0; ii < obj[i].group.length; ii++) {
  277. towerGroup_inner = towerGroup_inner + '<option value="' + obj[i].group[ii] + '">機組' + obj[i].group[ii] + '</option>';
  278. }
  279. }
  280. }
  281. }
  282. document.getElementById("towerGroup-list").innerHTML = towerGroup_inner;
  283. }
  284. function get_tower_perfrom(tower_id) {
  285. var xhr3 = new XMLHttpRequest();
  286. var url3 = "tower/performance/" + tower_id;
  287. console.log("sss");
  288. obj3 = "";
  289. xhr3.open("GET", url3);
  290. xhr3.onload = function () {
  291. obj3 = JSON.parse(xhr3.responseText);
  292. console.log(obj3);
  293. tower_perform_show(obj3);
  294. };
  295. xhr3.send();
  296. }
  297. function tower_perform_show(obj_tmp) {
  298. inner = "<div class='mt-5'>\
  299. <div>\
  300. <div class='row px-0 mx-0'>\
  301. <div class='col-lg-6'>\
  302. <div class='card h-100'>\
  303. <h1 style='color:#002e86'>設計條件</h1>\
  304. <div style='padding:15px'>\
  305. <table style='font-size: 16px; border-color:#4c6caa; border-top:1px solid #4c6caa;' class='table'>\
  306. <thead style='background:#e4f8ff; color:#4c6caa;'>\
  307. <tr>\
  308. <th class='border-0' scope='col'>數據名稱</th>\
  309. <th class='border-0' scope='col'>值</th>\
  310. <th class='border-0' scope='col'>單位</th>\
  311. </tr>\
  312. </thead>\
  313. <tbody>\
  314. <tr>\
  315. <td>水流量</td>\
  316. <td>" + obj_tmp[0].designWFR + "</td>\
  317. <td>M³/H</td>\
  318. </tr>\
  319. <tr>\
  320. <td>風車馬力</td>\
  321. <td>" + obj_tmp[0].designHP + "</td>\
  322. <td>mm/s</td>\
  323. </tr>\
  324. <tr>\
  325. <td>額定電流</td>\
  326. <td>" + obj_tmp[0].designCurrent + "</td>\
  327. <td>A</td>\
  328. </tr>\
  329. <tr>\
  330. <td>入水溫度</td>\
  331. <td>" + obj_tmp[0].designHWT + "</td>\
  332. <td>°C</td>\
  333. </tr>\
  334. <tr>\
  335. <td>出水溫度</td>\
  336. <td>" + obj_tmp[0].designCWT + "</td>\
  337. <td>°C</td>\
  338. </tr>\
  339. <tr>\
  340. <td>濕求溫度</td>\
  341. <td>" + obj_tmp[0].designWBT + "</td>\
  342. <td>°C</td>\
  343. </tr>\
  344. </tbody>\
  345. </table>\
  346. </div>\
  347. </div>\
  348. </div>\
  349. <div class='col-lg-6'>\
  350. <div class='card h-100'>\
  351. <h1 style='color:#002e86'>測試狀態</h1>\
  352. <div style='padding:15px'>\
  353. <table style='font-size: 16px; border-color:#4c6caa; border-top:1px solid #4c6caa;' class='table'>\
  354. <thead style='background:#e4f8ff; color:#4c6caa;'>\
  355. <tr>\
  356. <th class='border-0' scope='col'>數據名稱</th>\
  357. <th class='border-0' scope='col'>值</th>\
  358. <th class='border-0' scope='col'>單位</th>\
  359. </tr>\
  360. </thead>\
  361. <tbody>\
  362. <tr>\
  363. <td>水流量</td>\
  364. <td>" + obj_tmp[0].testWFR + "</td>\
  365. <td>M³/H</td>\
  366. </tr>\
  367. <tr>\
  368. <td>風車馬力</td>\
  369. <td> " + obj_tmp[0].testBHP + "</td>\
  370. <td>mm/s</td>\
  371. </tr>\
  372. <tr>\
  373. <td>運轉電流</td>\
  374. <td>" + obj_tmp[0].testCurrent + "</td>\
  375. <td>A</td>\
  376. </tr>\
  377. <tr>\
  378. <td>入水溫度</td>\
  379. <td>" + obj_tmp[0].testHWT + "</td>\
  380. <td>°C</td>\
  381. </tr>\
  382. <tr>\
  383. <td>出水溫度</td>\
  384. <td>" + obj_tmp[0].testCorrectCWT + "</td>\
  385. <td>°C</td>\
  386. </tr>\
  387. <tr>\
  388. <td>濕求溫度</td>\
  389. <td>" + obj_tmp[0].testWBT + "</td>\
  390. <td>°C</td>\
  391. </tr>\
  392. <tr>\
  393. <td>風速</td>\
  394. <td>" + obj_tmp[0].testWindSpeed + "</td>\
  395. <td>°C</td>\
  396. </tr>\
  397. <tr>\
  398. <td>補充水量</td>\
  399. <td>" + obj_tmp[0].testMakeupWFR + "</td>\
  400. <td>°C</td>\
  401. </tr>\
  402. <tr>\
  403. <td>補充水溫</td>\
  404. <td>" + obj_tmp[0].testMakeupCWT + "</td>\
  405. <td>°C</td>\
  406. </tr>\
  407. <tr>\
  408. <td>CORRECT CWT</td>\
  409. <td> " + obj_tmp[0].testCorrectCWT + "</td>\
  410. <td>°C</td>\
  411. </tr>\
  412. <tr>\
  413. <td>COLLING RANGE</td>\
  414. <td> " + obj_tmp[0].testCoolingRange + "</td>\
  415. <td>°C</td>\
  416. </tr>\
  417. </tbody>\
  418. </table>\
  419. </div>\
  420. </div>\
  421. </div>\
  422. </div>\
  423. </div>\
  424. </div>" ;
  425. // "測試狀態<br> " +
  426. // "水流量: " + obj_tmp[0].testWFR + "<br>" +
  427. // "風車馬力: " + obj_tmp[0].testBHP + "<br>" +
  428. // "運轉電流: " + obj_tmp[0].testCurrent + "<br>" +
  429. // "入水溫度: " + obj_tmp[0].testHWT + "<br>" +
  430. // "出水溫度: " + obj_tmp[0].testCorrectCWT + "<br>" +
  431. // "濕球溫度: " + obj_tmp[0].testWBT + "<br>" +
  432. // "風速: " + obj_tmp[0].testWindSpeed + "<br>" +
  433. // "補充水量: " + obj_tmp[0].testMakeupWFR + "<br>" +
  434. // "補充水溫: " + obj_tmp[0].testMakeupCWT + "<br>" +
  435. // "CORRECT CWT: " + obj_tmp[0].testCorrectCWT + "<br>" +
  436. // "COLLING RANGE: " + obj_tmp[0].testCoolingRange + "<br>";
  437. document.getElementById('tower_perfrom').innerHTML = inner;
  438. }
  439. // function tower_perform_show(obj_tmp){
  440. // inner = "設計條件<br>" +
  441. // "水流量: " + obj_tmp[0].designWFR + "<br>" +
  442. // "風車馬力: " + obj_tmp[0].designHP + "<br>" +
  443. // "額定電流: " + obj_tmp[0].designCurrent + "<br>" +
  444. // "入水溫度: " + obj_tmp[0].designHWT + "<br>" +
  445. // "出水溫度: " + obj_tmp[0].designCWT + "<br>" +
  446. // "濕求溫度: " + obj_tmp[0].designWBT + "<br>" +
  447. // "測試狀態<br> " +
  448. // "水流量: " + obj_tmp[0].testWFR + "<br>" +
  449. // "風車馬力: " + obj_tmp[0].testBHP + "<br>" +
  450. // "運轉電流: " + obj_tmp[0].testCurrent + "<br>" +
  451. // "入水溫度: " + obj_tmp[0].testHWT + "<br>" +
  452. // "出水溫度: " + obj_tmp[0].testCorrectCWT + "<br>" +
  453. // "濕球溫度: " + obj_tmp[0].testWBT + "<br>" +
  454. // "風速: " + obj_tmp[0].testWindSpeed + "<br>" +
  455. // "補充水量: " + obj_tmp[0].testMakeupWFR + "<br>" +
  456. // "補充水溫: " + obj_tmp[0].testMakeupCWT + "<br>" +
  457. // "CORRECT CWT: " + obj_tmp[0].testCorrectCWT + "<br>" +
  458. // "COLLING RANGE: " + obj_tmp[0].testCoolingRange + "<br>" ;
  459. // document.getElementById('tower_perfrom').innerHTML=inner;
  460. // }
  461. get_predict();
  462. function get_predict() {
  463. var xhr = new XMLHttpRequest();
  464. var url = "channel_predict/dev001/ch01";
  465. obj3 = "";
  466. xhr.open("GET", url);
  467. xhr.onload = function () {
  468. obj3 = JSON.parse(xhr.responseText);
  469. labels = new Array();
  470. for (var i = 0; i < obj3.data.length; i++) {
  471. labels.push(i);
  472. }
  473. console.log(obj3);
  474. var Data = {
  475. labels: labels, //顯示區間名稱
  476. datasets: [{
  477. label: "predict", // tootip 出現的名稱
  478. lineTension: 0, // 曲線的彎度,設0 表示直線
  479. backgroundColor: "#ea464d",
  480. borderColor: "#ea464d",
  481. borderWidth: 5,
  482. data: obj3.data, // 資料
  483. fill: false, // 是否填滿色彩
  484. },]
  485. };
  486. var ctx = document.getElementById("channel_predict").getContext("2d");
  487. drawLineCanvas(ctx, Data);
  488. };
  489. xhr.send();
  490. }
  491. function drawLineCanvas(ctx, data) {
  492. window.myLine = new Chart(ctx, { //先建立一個 chart
  493. type: 'line', // 型態
  494. data: data,
  495. showSymbol: false,
  496. options: {
  497. responsive: true,
  498. legend: { //是否要顯示圖示
  499. display: true,
  500. },
  501. tooltips: { //是否要顯示 tooltip
  502. enabled: true
  503. },
  504. scales: { //是否要顯示 x、y 軸
  505. xAxes: [{
  506. display: true
  507. }],
  508. yAxes: [{
  509. display: true
  510. }]
  511. },
  512. }
  513. });
  514. };