-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (27 loc) · 967 Bytes
/
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
let elList = document.getElementById("demo");
let API = "https://dummyjson.com/products";
fetch(API).then((response) => response.json()).then((data) => {
data.products.map((item) => {
const ctx = document.getElementById('myChart');
new Chart(ctx, {
type: 'line',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange', '', 'Blue'],
datasets: [{
label: '# of Votes',
data: [item.rating, item.rating, item.price, item.discountPercentage, item.price, item.rating, item.rating, item.price, item.rating, item.price, item.price, item.stock, item.price, item.discountPercentage],
borderWidth: 2,
width:"10px",
color: "red"
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
});
})