-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopexportcommodity.js
69 lines (65 loc) · 1.78 KB
/
topexportcommodity.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
59
60
61
62
63
64
65
66
67
68
69
// Define the data
const commodities = [
"MINERAL FUELS, MINERAL OILS AND PRODUCTS",
"PEARLS, PRECIOUS STONES, METALS, JEWELRY",
"NUCLEAR REACTORS, BOILERS, MACHINERY",
"VEHICLES AND PARTS",
"ORGANIC CHEMICALS",
"PHARMACEUTICAL PRODUCTS",
"ELECTRICAL MACHINERY, RECORDERS, TV PARTS",
"IRON AND STEEL",
"CEREALS",
"APPAREL AND CLOTHING ACCESSORIES"
].reverse();
const values = [
573781.24, 484859.9, 189003.07, 174616.34, 170491.42,
156859.86, 139396.39, 120904.29, 97642.07, 96902.61
].reverse();
// Initialize the chart
const ctx_exp = document.getElementById('barChart-export').getContext('2d');
new Chart(ctx_exp, {
type: 'bar',
data: {
labels: commodities,
datasets: [{
label: 'Value in USD Million',
data: values,
backgroundColor: 'skyblue',
borderColor: 'blue',
borderWidth: 1
}]
},
options: {
indexAxis: 'y', // Display bars horizontally
scales: {
x: {
beginAtZero: true,
title: {
display: true,
text: 'Value in USD Million',
color: '#fff'
},
ticks: {
color: '#fff'
}
},
y: {
title: {
display: true,
text: 'Commodities',
color: '#fff'
},
ticks: {
color: '#fff'
}
}
},
plugins: {
legend: {
display: false // Disable legend since we only have one dataset
}
},
responsive: true,
maintainAspectRatio: false
}
});