blob: bb14426b14f8ec86a5c64d5d813029e093db8eff (
plain) (
blame)
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
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Covid UK</title>
</head>
<body>
<canvas id="myChart" width="400" height="400"></canvas>
<script src="./node_modules/chart.js/dist/Chart.bundle.min.js"></script>
<script>
var timeseries =
fetch('https://pomber.github.io/covid19/timeseries.json')
.then(res => res.json())
.then(createChart);
function createChart(data) {
var uk = data["United Kingdom"];
var data = uk.map(x => x["confirmed"])
var labels = uk.map(x => x["date"])
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'Number of confirmed COVID-19 cases in the U.K.',
data: data,
backgroundColor: 'rgba(255, 0, 100, 0.2)',
borderWidth: 3
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
}
</script>
</body>
</html>
|