-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (46 loc) · 1.16 KB
/
app.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
document.addEventListener('DOMContentLoaded', function () {
axios
.get('json/profit.json')
.then((response) => {
const profitData = response.data;
const years = profitData.map((data) => data.Year);
const profit = profitData.map((data) => data.Profit);
const ctx = document.getElementById('lib=neChart').getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: years,
datasets: [
{
label: 'Revenue',
data: revenues,
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
},
],
},
options: {
responsive: true,
scales: {
x: {
display: true,
title: {
display: true,
text: 'Year',
},
},
y: {
display: true,
title: {
display: true,
text: 'Revenue',
},
},
},
},
});
})
.catch((error) => {
console.error(error);
});
});