-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
58 lines (54 loc) · 1.49 KB
/
script.js
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
fetch(
"https://api.apify.com/v2/key-value-stores/toDWvRj1JpTXiM8FF/records/LATEST?disableRedirect=true"
)
.then((response) => {
return response.json();
})
.then((data) => {
// console.log(data);
getdata(data);
})
.catch((err) => console.log(err));
function getdata(data) {
// console.log(data);
xlabel = [];
ylabel = [];
for (var i = 0; i < data.regionData.length; i++) {
xlabel.push(data.regionData[i].region);
ylabel.push(data.regionData[i].activeCases);
}
// console.log(xlabel);
// console.log(ylabel);
const ctx = document.getElementById("Chart").getContext("2d");
const myChart = new Chart(ctx, {
type: "bar",
data: {
labels:xlabel,
datasets:[
{
label:"covid-19 cases",
data:ylabel,
backgroundColor:['rgba(255, 99, 132, 0.2)'],
borderColor: ["rgba(255, 99, 132, 1)"],
borderWidth: 1,
},
],
},
});
}
// const ctx = document.getElementById("Chart").getContext("2d");
// const myChart = new Chart(ctx, {
// type: "bar",
// data: {
// labels: xlabel,
// datasets: [
// {
// label: "covid cases",
// data: ylabel,
// backgroundColor: ["rgba(255, 99, 132, 0.2)"],
// borderColor: ["rgba(255, 99, 132, 1)"],
// borderWidth: 1,
// },
// ],
// }}
//