-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (51 loc) · 1.33 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>MIT Histogram</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://cdn.plot.ly/plotly-2.12.1.min.js"></script>
</head>
<body>
<div id="plot"></div>
<script>
let dates = [];
let dateCounts = [];
fetch("/dates.json")
.then((response) => response.json())
.then((data) => {
data.entries.forEach((date) => {
dates.push(date.key);
dateCounts.push(date.count);
});
})
.then(() => {
var myPlotDiv = document.getElementById("plot");
let chartData = [
{
x: dates,
y: dateCounts,
type: "bar",
marker: {
color: "black",
},
},
];
let layout = {
title: "MIT object dates",
xaxis: {
title: "Date",
},
yaxis: {
title: "Frequency",
},
};
Plotly.newPlot(myPlotDiv, chartData, layout);
myPlotDiv.on("plotly_relayout", function (e) {
console.log(e);
});
});
</script>
</body>
</html>