KuRRe8 commited on
Commit
c379b59
·
verified ·
1 Parent(s): 13ea96f

第一个曲线图中,我想增加一个时间段选择的控件在上面,列车号选择器,然后有个确定按钮。

Browse files
Files changed (3) hide show
  1. index.html +29 -10
  2. script.js +13 -3
  3. style.css +7 -0
index.html CHANGED
@@ -48,14 +48,33 @@
48
  <main class="flex-grow container mx-auto px-4 py-8">
49
  <!-- Chart Section -->
50
  <section class="mb-12 bg-white rounded-xl shadow-md overflow-hidden">
51
- <div class="p-6 border-b border-gray-200">
52
- <h2 class="text-xl font-semibold text-gray-800 flex items-center">
53
- <i data-feather="activity" class="mr-2 text-indigo-500"></i>
54
- Sensor Metrics Overview
55
- </h2>
56
- <p class="text-gray-500 mt-1">Real-time monitoring with anomaly detection</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  </div>
58
- <div id="chartContainer" class="w-full h-96 p-4"></div>
59
  </section>
60
 
61
  <!-- Table Section -->
@@ -67,9 +86,9 @@
67
  </h2>
68
  <p class="text-gray-500 mt-1">Last 24 hours of detected issues</p>
69
  </div>
70
- <div class="overflow-x-auto">
71
- <table class="min-w-full divide-y divide-gray-200">
72
- <thead class="bg-gray-50">
73
  <tr>
74
  <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Sensor ID</th>
75
  <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Metric</th>
 
48
  <main class="flex-grow container mx-auto px-4 py-8">
49
  <!-- Chart Section -->
50
  <section class="mb-12 bg-white rounded-xl shadow-md overflow-hidden">
51
+ <div class="p-6 border-b border-gray-200 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
52
+ <div>
53
+ <h2 class="text-xl font-semibold text-gray-800 flex items-center">
54
+ <i data-feather="activity" class="mr-2 text-indigo-500"></i>
55
+ Sensor Metrics Overview
56
+ </h2>
57
+ <p class="text-gray-500 mt-1">Real-time monitoring with anomaly detection</p>
58
+ </div>
59
+ <div class="flex flex-wrap gap-2">
60
+ <select class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-indigo-500 focus:border-indigo-500 px-3 py-2">
61
+ <option selected>Select Train Number</option>
62
+ <option value="T-001">T-001</option>
63
+ <option value="T-002">T-002</option>
64
+ <option value="T-003">T-003</option>
65
+ </select>
66
+ <select class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-indigo-500 focus:border-indigo-500 px-3 py-2">
67
+ <option selected>Last 24 hours</option>
68
+ <option value="6h">Last 6 hours</option>
69
+ <option value="12h">Last 12 hours</option>
70
+ <option value="7d">Last 7 days</option>
71
+ </select>
72
+ <button class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors">
73
+ Apply
74
+ </button>
75
+ </div>
76
  </div>
77
+ <div id="chartContainer" class="w-full h-96 p-4"></div>
78
  </section>
79
 
80
  <!-- Table Section -->
 
86
  </h2>
87
  <p class="text-gray-500 mt-1">Last 24 hours of detected issues</p>
88
  </div>
89
+ <div class="overflow-x-auto max-h-96 overflow-y-auto">
90
+ <table class="min-w-full divide-y divide-gray-200 sticky-header">
91
+ <thead class="bg-gray-50">
92
  <tr>
93
  <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Sensor ID</th>
94
  <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Metric</th>
script.js CHANGED
@@ -104,13 +104,23 @@ document.addEventListener('DOMContentLoaded', function() {
104
  };
105
 
106
  myChart.setOption(option);
107
-
108
  // Handle window resize
109
  window.addEventListener('resize', function() {
110
  myChart.resize();
111
  });
112
-
113
- // Populate table with sample data
 
 
 
 
 
 
 
 
 
 
 
114
  const anomalyData = [
115
  { id: 'S-001', metric: 'Temperature', value: '35°C', threshold: '30°C', timestamp: '2023-06-15 05:12:34', status: 'critical' },
116
  { id: 'S-002', metric: 'Pressure', value: '12.5 bar', threshold: '10 bar', timestamp: '2023-06-15 08:45:21', status: 'warning' },
 
104
  };
105
 
106
  myChart.setOption(option);
 
107
  // Handle window resize
108
  window.addEventListener('resize', function() {
109
  myChart.resize();
110
  });
111
+
112
+ // Add event listener for the Apply button
113
+ document.querySelector('.bg-indigo-600').addEventListener('click', function() {
114
+ const trainNumber = document.querySelector('select:first-of-type').value;
115
+ const timeRange = document.querySelector('select:last-of-type').value;
116
+
117
+ // Here you would typically fetch new data based on the selections
118
+ console.log(`Fetching data for train ${trainNumber} and time range ${timeRange}`);
119
+
120
+ // For demo purposes, we'll just show an alert
121
+ alert(`Filters applied: Train ${trainNumber}, Time Range ${timeRange}`);
122
+ });
123
+ // Populate table with sample data
124
  const anomalyData = [
125
  { id: 'S-001', metric: 'Temperature', value: '35°C', threshold: '30°C', timestamp: '2023-06-15 05:12:34', status: 'critical' },
126
  { id: 'S-002', metric: 'Pressure', value: '12.5 bar', threshold: '10 bar', timestamp: '2023-06-15 08:45:21', status: 'warning' },
style.css CHANGED
@@ -35,6 +35,13 @@ body {
35
  height: 300px;
36
  }
37
  }
 
 
 
 
 
 
 
38
 
39
  /* Table row hover effect */
40
  tbody tr {
 
35
  height: 300px;
36
  }
37
  }
38
+ /* Sticky table header */
39
+ .sticky-header thead th {
40
+ position: sticky;
41
+ top: 0;
42
+ background-color: #f9fafb;
43
+ z-index: 10;
44
+ }
45
 
46
  /* Table row hover effect */
47
  tbody tr {