-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsector-wise.html
120 lines (117 loc) · 4.36 KB
/
sector-wise.html
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pie Charts - Import and Export</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels"></script>
</head>
<body>
<div class="container mt-5">
<h2 class="text-center">Sector-wise Composition of Imports and Exports</h2>
<div class="row justify-content-center">
<!-- Export Pie Chart -->
<div class="col-md-5">
<h4 class="text-center">Export</h4>
<canvas id="exportPieChart"></canvas>
</div>
<!-- Import Pie Chart -->
<div class="col-md-5">
<h4 class="text-center">Import</h4>
<canvas id="importPieChart"></canvas>
</div>
</div>
</div>
<script>
// Export Pie Chart
const exportCtx = document.getElementById('exportPieChart').getContext('2d');
const exportPieChart = new Chart(exportCtx, {
type: 'pie',
data: {
labels: ['Primary (1154532.83)', 'Secondary (1786807.56)', 'Tertiary (99201.76)'],
datasets: [{
label: 'Export',
data: [38.0, 58.8, 3.3],
backgroundColor: ['#36a2eb', '#ff6384', '#ffcd56'],
borderWidth: 1,
}]
},
options: {
responsive: true,
plugins: {
legend: {
display: true,
position: 'top'
},
tooltip: {
callbacks: {
label: function(tooltipItem) {
const label = tooltipItem.label || '';
const value = tooltipItem.raw || 0;
return `${label}: ${value}%`;
}
}
},
datalabels: {
color: '#fff',
formatter: (value) => {
return value + '%';
},
font: {
weight: 'bold',
size: 16
}
}
}
},
plugins: [ChartDataLabels]
});
// Import Pie Chart
const importCtx = document.getElementById('importPieChart').getContext('2d');
const importPieChart = new Chart(importCtx, {
type: 'pie',
data: {
labels: ['Primary (2345994.37)', 'Secondary (2509019.75)', 'Tertiary (169150.17)'],
datasets: [{
label: 'Import',
data: [46.7, 49.9, 3.4],
backgroundColor: ['#4bc0c0', '#ff9f40', '#9966ff'],
borderWidth: 1,
}]
},
options: {
responsive: true,
plugins: {
legend: {
display: true,
position: 'top'
},
tooltip: {
callbacks: {
label: function(tooltipItem) {
const label = tooltipItem.label || '';
const value = tooltipItem.raw || 0;
return `${label}: ${value}%`;
}
}
},
datalabels: {
color: '#fff',
formatter: (value) => {
return value + '%';
},
font: {
weight: 'bold',
size: 16
}
}
}
},
plugins: [ChartDataLabels]
});
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>