-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
92 lines (71 loc) · 3.17 KB
/
index.html
File metadata and controls
92 lines (71 loc) · 3.17 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", { packages: ["timeline"] });
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Check if we have valid data before drawing
if (!window.timelineData || window.timelineData.length === 0) {
return;
}
const container = document.getElementById('timeline');
if (!container || container.style.display === 'none') {
return;
}
try {
const chart = new google.visualization.Timeline(container);
const dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Event' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
// Validate and add rows
const validData = window.timelineData.filter(row => {
return row && row.length === 3 &&
typeof row[0] === 'string' &&
row[1] instanceof Date && !isNaN(row[1].getTime()) &&
row[2] instanceof Date && !isNaN(row[2].getTime());
});
if (validData.length === 0) {
return;
}
dataTable.addRows(validData);
const options = {
timeline: { showRowLabels: true },
avoidOverlappingGridLines: false,
};
chart.draw(dataTable, options);
} catch (error) {
console.warn('Timeline chart error:', error);
// Hide timeline if there's an error
container.style.display = 'none';
}
}
</script>
<script type='module' src="./js/main.js" defer></script>
</head>
<body>
<div class="container">
<form id="event-form">
<label for="event-name">Event Name</label>
<input type="text" id="event-name" name="event-name" required>
<label for="event-start-time">Event Start Time</label>
<input type="datetime-local" id="event-start-time" name="event-start-time" required>
<label for="event-end-time">Event End Time</label>
<input type="datetime-local" id="event-end-time" name="event-end-time">
<input type="submit" value="Add event"></input>
</form>
<ul id="events">
<!-- Events will be populated dynamically -->
</ul>
<div id="timeline" style="min-height: 500px"></div>
</div>
</body>
</html>