This repository has been archived by the owner on Sep 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
54 lines (46 loc) · 1.59 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Timeline of Chinese Dynasties</title>
<style>
html, body, #timeline {
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/jquery" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://www.gstatic.cn/charts/loader.js"></script>
<script type="text/javascript">
window.google.charts.load('current', { packages: ['timeline'] });
window.google.charts.setOnLoadCallback(() => {
const dataTable = new window.google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Dynasties' });
dataTable.addColumn({ type: 'string', id: 'Dynasty' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
$.ajax('dynasties.json', { cache: false }).done((json) => {
const data = json;
for (let i = 0; i < data.length; i += 1) {
for (let j = 2; j < 4; j += 1) {
const d = new Date(undefined, undefined);
d.setFullYear(data[i][j][0] || data[i][j]);
if (data[i][j][1]) {
d.setMonth(data[i][j][1] - 1);
}
if (data[i][j][2]) {
d.setDate(data[i][j][2]);
}
data[i][j] = d;
}
}
dataTable.addRows(data);
new window.google.visualization.Timeline(document.getElementById('timeline')).draw(dataTable);
});
});
</script>
</head>
<body>
<div id="timeline" style="max-height: 1025px; min-width: 1578px;"></div>
</body>
</html>