-
Notifications
You must be signed in to change notification settings - Fork 2
/
dashboard.html
207 lines (174 loc) · 6.06 KB
/
dashboard.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Live Dashboard with Real-time Graphs</title>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.css" />
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #f4f6f8;
color: #333;
}
h1 {
text-align: center;
margin-top: 20px;
color: #333;
font-size: 36px;
}
nav {
background-color: #2c3e50;
padding: 15px 0;
text-align: center;
}
nav a {
color: #ecf0f1;
margin: 0 20px;
font-size: 18px;
text-decoration: none;
}
nav a:hover {
color: #3498db;
}
#dashboard {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
padding: 20px;
padding-bottom: 100px;
}
.card {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
text-align: center;
transition: transform 0.3s ease;
}
.card:hover {
transform: scale(1.05);
}
.active {
display: block;
}
.card h3 {
font-size: 24px;
margin-bottom: 10px;
}
#map {
height: 300px;
width: 100%;
border-radius: 8px;
}
footer {
background-color: #2c3e50;
color: #ecf0f1;
padding: 20px;
text-align: center;
width: 100%;
position: relative;
bottom: 0;
}
footer a {
color: #3498db;
text-decoration: none;
}
footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<nav>
<a href="#line-chart-card">ECG Graph <a href="ecg.html">More about ECG</a></a>
<a href="#activity-chart-card">Activity Levels</a>
<a href="#pie-chart-card">Delivery Timings</a>
<a href="#map-card">Current Location</a>
<a href="#device-status-card">Device Status</a>
</nav>
<h1>Live Dashboard</h1>
<div id="dashboard">
<div id="line-chart-card" class="card active">
<h3>ECG Graph (Electrocardiogram)</h3>
<div id="ecg-graph"></div>
</div>
<div id="activity-chart-card" class="card">
<h3>Vehicle Activity Levels</h3>
<div id="activity-chart"></div>
</div>
<div id="pie-chart-card" class="card">
<h3>Delivery Timings Distribution</h3>
<div id="pie-chart"></div>
</div>
<div id="map-card" class="card">
<h3>Current Location</h3>
<div id="map"></div>
</div>
<div id="device-status-card" class="card">
<h3>Device Status</h3>
<div id="device-status-graph"></div>
</div>
</div>
<footer>
<p>©️ 2024 TrackGuard. All rights reserved.</p>
</footer>
<script>
function getRandomData(arrayLength, range) {
return Array.from({ length: arrayLength }, () => Math.random() * range);
}
function updateGraphs() {
const ecgTrace = {
x: Array.from({ length: 100 }, (_, i) => new Date(Date.now() + i * 1000)),
y: getRandomData(100, 1),
mode: 'lines',
name: 'ECG (mV)',
line: { color: 'rgb(255, 99, 132)' }
};
const layoutECG = { title: 'ECG (Electrocardiogram)' };
Plotly.newPlot('ecg-graph', [ecgTrace], layoutECG);
const activityTrace = {
x: ['Idle', 'In Motion', 'Stopped', 'Off Route'],
y: getRandomData(4, 100),
type: 'bar',
marker: { color: 'rgb(54, 162, 235)' }
};
const layoutActivity = { title: 'Vehicle Activity Levels' };
Plotly.newPlot('activity-chart', [activityTrace], layoutActivity);
const pieTrace = {
labels: ['On-time Delivery', 'Delayed Delivery', 'Early Delivery', 'Canceled Delivery'],
values: getRandomData(4, 100),
type: 'pie'
};
const layoutPie = { title: 'Delivery Timings Distribution' };
Plotly.newPlot('pie-chart', [pieTrace], layoutPie);
const deviceStatusTrace = {
x: ['Active', 'Inactive', 'Partially Active'],
y: getRandomData(3, 50),
type: 'bar',
marker: { color: 'rgb(75, 192, 192)' }
};
const layoutDeviceStatus = { title: 'Device Status Distribution' };
Plotly.newPlot('device-status-graph', [deviceStatusTrace], layoutDeviceStatus);
}
setInterval(updateGraphs, 3000);
let map = L.map('map').setView([20.5937, 78.9629], 5);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
let marker = L.marker([28.6139, 77.2090]).addTo(map);
setInterval(() => {
const lat = 20.5937 + (Math.random() - 0.3) * 10;
const lon = 78.9629 + (Math.random() - 0.3) * 10;
marker.setLatLng([lat, lon]);
map.setView([lat, lon], 5);
marker.bindPopup("The driver is here").openPopup();
}, 5000);
updateGraphs();
</script>
</body>
</html>