-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharts3.js
42 lines (38 loc) · 1.23 KB
/
charts3.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
document.addEventListener('DOMContentLoaded', function () {
const ctx = document.getElementById('line');
fetch('./data/mechine.json')
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then((data) => {
const uniqueData = _.uniqBy(data, 'Product');
const products = uniqueData.map((item) => {
return item.Product;
});
const RPrice = uniqueData.map((item) => {
return item.RPrice;
});
console.log(products);
console.log(RPrice);
new Chart(ctx, {
type: 'line',
data: {
labels: products,
datasets: [{
label: 'order per Products',
data:RPrice,
borderWidth: 1
}]
},
options: {
responsive: true
}
});
})
.catch((error) => {
console.error('Error fetching or parsing data:', error);
});
});