File size: 6,442 Bytes
8e5e288 6915dd3 8e5e288 e29b324 ee17264 8e5e288 6915dd3 ee17264 6915dd3 ee17264 6915dd3 8e5e288 b871f96 8e5e288 9de9110 b3405c1 9de9110 b3405c1 9de9110 b3405c1 9de9110 | 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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
document.addEventListener('DOMContentLoaded', function() {
// Data from Global Forest Watch and FAO (2023 estimates) for deforestation
const deforestationData = [
{ country: 'Brazil', percentage: 31.2, color: '#FF3333' },
{ country: 'Indonesia', percentage: 12.8, color: '#3399FF' },
{ country: 'D.R. Congo', percentage: 9.5, color: '#33CC99' },
{ country: 'Southeast Asia', percentage: 18.3, color: '#FF9933', countries: ['Myanmar', 'Thailand', 'Laos', 'Vietnam', 'Cambodia', 'Malaysia', 'Philippines'] },
{ country: 'Colombia', percentage: 6.7, color: '#FFCC33' },
{ country: 'Bolivia', percentage: 5.4, color: '#CC66FF' },
{ country: 'Peru', percentage: 4.9, color: '#FF66CC' },
{ country: 'Other Countries', percentage: 11.2, color: '#999999' }
];
// Create deforestation chart
const deforestaionCtx = document.getElementById('deforestationChart').getContext('2d');
const deforestationChart = new Chart(deforestaionCtx, {
type: 'pie',
data: {
labels: deforestationData.map(item => item.country),
datasets: [{
data: deforestationData.map(item => item.percentage),
backgroundColor: deforestationData.map(item => item.color),
borderWidth: 1,
borderColor: '#fff'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'right',
labels: {
boxWidth: 12,
padding: 20,
font: {
size: 14
}
}
},
tooltip: {
callbacks: {
label: function(context) {
const dataItem = deforestationData[context.dataIndex];
let tooltip = `${context.label}: ${context.raw}%`;
if (dataItem.countries) {
tooltip += ` (Includes: ${dataItem.countries.join(', ')})`;
}
return tooltip;
}
}
},
datalabels: {
display: false
}
},
cutout: '50%',
animation: {
animateScale: true,
animateRotate: true
}
}
});
// Oil Palm Cultivation Data (FAO, World Bank)
const oilPalmData = {
labels: ['1961', '1970', '1980', '1990', '2000', '2006'],
datasets: [{
label: 'Oil Palm Cultivation (Million Hectares)',
data: [3.6, 4.2, 5.8, 8.1, 10.7, 13.2],
backgroundColor: 'rgba(255, 159, 64, 0.2)',
borderColor: 'rgba(255, 159, 64, 1)',
borderWidth: 2,
tension: 0.3,
fill: true
}]
};
// Create oil palm cultivation chart
const oilPalmCtx = document.createElement('canvas');
oilPalmCtx.id = 'oilPalmChart';
document.querySelector('.chart-container').insertAdjacentElement('afterend', oilPalmCtx);
const oilPalmChart = new Chart(oilPalmCtx.getContext('2d'), {
type: 'line',
data: oilPalmData,
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'Global Palm Oil Cultivation Growth (1961-2006)',
font: {
size: 16
}
},
legend: {
position: 'top',
},
tooltip: {
callbacks: {
label: function(context) {
return `${context.dataset.label}: ${context.raw} million ha`;
}
}
}
},
scales: {
y: {
beginAtZero: false,
min: 3,
title: {
display: true,
text: 'Area (Million Hectares)'
}
},
x: {
title: {
display: true,
text: 'Year'
}
}
}
}
});
// Price comparison data per gram (2023 estimates)
const priceData = {
labels: ['Sun Bear Gallbladder (black market)', 'Gold', 'Platinum'],
datasets: [{
label: 'Price per gram (USD)',
data: [153, 135, 48],
backgroundColor: [
'rgba(139, 69, 19, 0.7)',
'rgba(255, 215, 0, 0.7)',
'rgba(229, 228, 226, 0.7)'
],
borderColor: [
'rgba(139, 69, 19, 1)',
'rgba(255, 215, 0, 1)',
'rgba(229, 228, 226, 1)'
],
borderWidth: 1
}]
};
// Create price comparison chart
const priceCtx = document.createElement('canvas');
priceCtx.id = 'priceComparisonChart';
document.getElementById('oilPalmChart').parentNode.parentNode.insertAdjacentElement('afterend', priceCtx);
new Chart(priceCtx, {
type: 'bar',
data: priceData,
options: {
indexAxis: 'y',
responsive: true,
plugins: {
title: {
display: true,
text: 'Price Comparison per Gram (USD)',
font: {
size: 16
}
},
legend: {
display: false
},
tooltip: {
callbacks: {
label: function(context) {
return `${context.raw.toLocaleString()}/gram`;
}
}
}
},
scales: {
x: {
beginAtZero: true,
title: {
display: true,
text: 'Price per gram (USD)'
}
}
}
}
});
});
|