|
@@ -36,7 +36,6 @@
|
|
|
|
|
|
|
|
ctx.font = 'bold 20px sans-serif';
|
|
ctx.font = 'bold 20px sans-serif';
|
|
|
|
|
|
|
|
- // ✅ Dynamically read computed text color from a hidden DOM element
|
|
|
|
|
const probe = document.getElementById('chart-text-color');
|
|
const probe = document.getElementById('chart-text-color');
|
|
|
const computedColor = getComputedStyle(probe)?.color;
|
|
const computedColor = getComputedStyle(probe)?.color;
|
|
|
ctx.fillStyle = computedColor || '#333';
|
|
ctx.fillStyle = computedColor || '#333';
|
|
@@ -109,7 +108,12 @@
|
|
|
tooltip: {
|
|
tooltip: {
|
|
|
callbacks: {
|
|
callbacks: {
|
|
|
label: function (tooltipItem) {
|
|
label: function (tooltipItem) {
|
|
|
- return `${tooltipItem.label}: ${formatCurrency(tooltipItem.raw, currency)}`;
|
|
|
|
|
|
|
+ const value = tooltipItem.raw;
|
|
|
|
|
+ const dataset = tooltipItem.chart.data.datasets[tooltipItem.datasetIndex];
|
|
|
|
|
+ const data = dataset.data;
|
|
|
|
|
+ const total = data.reduce((sum, val) => sum + val, 0);
|
|
|
|
|
+ const percentage = total ? ((value / total) * 100).toFixed(2) : '0.00';
|
|
|
|
|
+ return `${formatCurrency(value, currency)} (${percentage}%)`;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|