From 0e983cca4f210a48427aea6eadb2262cfc656711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A8=81=E5=8B=9D=20=E5=BC=B5?= Date: Tue, 6 Feb 2024 13:04:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9C=93=E9=A4=85=E5=9C=96?= =?UTF-8?q?=20=E5=8F=8A=20=E8=80=85=E7=B7=9A=E5=9C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Engineering/Engineering_Index.cshtml | 65 +++- .../Engineering/Engineering_Violation.cshtml | 291 +++++++++++++++++- 2 files changed, 342 insertions(+), 14 deletions(-) diff --git a/Parking_spaces/Views/Engineering/Engineering_Index.cshtml b/Parking_spaces/Views/Engineering/Engineering_Index.cshtml index 80785ff..9cafa80 100644 --- a/Parking_spaces/Views/Engineering/Engineering_Index.cshtml +++ b/Parking_spaces/Views/Engineering/Engineering_Index.cshtml @@ -192,16 +192,16 @@
- +
-
+
每日車流量
-
+
@@ -235,9 +235,56 @@ var dailyTrafficData = dailyTrafficData // 取得 canvas 元素 - var ctx = document.getElementById('in_car_Bar') + var ctx1 = document.getElementById('in_car_Bar') + // 使用 Chart.js 繪製長條圖 + var myLineChart = new Chart(ctx1, { + type: 'line', + data: { + labels: date.reverse(), + datasets: [{ + label: '車流量', + data: values.reverse(), + backgroundColor: 'rgba(75, 192, 192, 0.2)', // 設定背景色 + borderColor: 'rgba(75, 192, 192, 1)', // 設定邊框色 + pointHitRadius: 10, + pointBorderWidth: 2, + ineTension: 0.3, + pointRadius: 3, + pointHoverRadius: 3, + }] + }, + options: { + responsive: true, // 啟用 responsive 設置 + maintainAspectRatio: false, // 保持長寬比例 + scales: { + y: { + beginAtZero: true + }, + xAxes: { + gridLines: { + display: false // 移除 x 軸的網格線 + } + } + } + } + }); + + + + } + + function set_in_yuntech_table_1(labels, dailyTrafficData) { + date = JSON.parse(JSON.stringify(labels)); + values = JSON.parse(JSON.stringify(dailyTrafficData)); + // 假設你有一些資料,例如每日車流量 + var dailyTrafficData = dailyTrafficData + + // 取得 canvas 元素 + var ctx = document.getElementById('in_car_Bar') + + // 使用 Chart.js 繪製長條圖 var myBarChart = new Chart(ctx, { type: 'bar', @@ -262,8 +309,8 @@ } }); - - + + } @@ -403,7 +450,7 @@ var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24) - if (daysDifference > 6) { + if (daysDifference > 29) { console.log(date_list) break } @@ -465,7 +512,7 @@ var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24) ////console.log(daysDifference) - if (daysDifference > 6) { + if (daysDifference > date_list.length) { break } var D_1 = new Date(date); @@ -556,7 +603,7 @@ var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24) ////console.log(daysDifference) - if (daysDifference > 6) { + if (daysDifference > date_list.length) { break } var D_1 = new Date(date); diff --git a/Parking_spaces/Views/Engineering/Engineering_Violation.cshtml b/Parking_spaces/Views/Engineering/Engineering_Violation.cshtml index fb6d8a7..93de2a3 100644 --- a/Parking_spaces/Views/Engineering/Engineering_Violation.cshtml +++ b/Parking_spaces/Views/Engineering/Engineering_Violation.cshtml @@ -37,13 +37,13 @@
- +
- 違規累犯 - + 每日違規數量 +
@@ -53,9 +53,114 @@
+ +
+
+
+
+ 違規次數 + +
+
+
+
+ +
+
+
+
+ + + + + + + + + +