Skip to content

Commit 998e71b

Browse files
committed
feat: add verification rate chart to statistics
1 parent ab4f0a2 commit 998e71b

1 file changed

Lines changed: 53 additions & 1 deletion

File tree

docs/statistics.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@
266266
</div>
267267
</div>
268268

269+
<div class="chart-section">
270+
<div class="chart-title">📉 Verification Rate</div>
271+
<div class="chart-wrapper">
272+
<canvas id="verificationRateChart"></canvas>
273+
</div>
274+
<div class="legend">
275+
<div class="legend-item"><span class="legend-dot gold"></span> Verified / Emails Sent (%)</div>
276+
</div>
277+
</div>
278+
269279
<div class="chart-section">
270280
<div class="chart-title">📈 Total Users Verified</div>
271281
<div class="chart-wrapper">
@@ -360,7 +370,7 @@ const autoScaleOptions = {
360370
}
361371
};
362372

363-
let dailyChart, verifiedTotalChart, emailsTotalChart, serversChart;
373+
let dailyChart, verificationRateChart, verifiedTotalChart, emailsTotalChart, serversChart;
364374
let currentDays = 7;
365375

366376
function formatNumber(num) {
@@ -428,6 +438,7 @@ async function updateCharts(days) {
428438

429439
// Destroy existing charts
430440
if (dailyChart) dailyChart.destroy();
441+
if (verificationRateChart) verificationRateChart.destroy();
431442
if (verifiedTotalChart) verifiedTotalChart.destroy();
432443
if (emailsTotalChart) emailsTotalChart.destroy();
433444
if (serversChart) serversChart.destroy();
@@ -445,6 +456,47 @@ async function updateCharts(days) {
445456
options: baseOptions
446457
});
447458

459+
// Verification Rate Chart
460+
const verificationRate = history.map(h => {
461+
if (h.mailsSendToday === 0) return 0;
462+
return Math.min(((h.usersVerifiedToday / h.mailsSendToday) * 100), 100);
463+
});
464+
465+
verificationRateChart = new Chart(document.getElementById('verificationRateChart'), {
466+
type: 'line',
467+
data: {
468+
labels: labels,
469+
datasets: [
470+
createDataset(verificationRate, 'rgba(212, 148, 10, 1)', 'Verification Rate (%)')
471+
]
472+
},
473+
options: {
474+
...baseOptions,
475+
scales: {
476+
...baseOptions.scales,
477+
y: {
478+
...baseOptions.scales.y,
479+
beginAtZero: true,
480+
max: 100,
481+
ticks: {
482+
...baseOptions.scales.y.ticks,
483+
callback: function(value) { return value + '%'; }
484+
}
485+
}
486+
},
487+
plugins: {
488+
...baseOptions.plugins,
489+
tooltip: {
490+
callbacks: {
491+
label: function(context) {
492+
return context.dataset.label + ': ' + context.parsed.y.toFixed(1) + '%';
493+
}
494+
}
495+
}
496+
}
497+
}
498+
});
499+
448500
// Total Users Verified Chart (auto-scale, not starting at 0)
449501
verifiedTotalChart = new Chart(document.getElementById('verifiedTotalChart'), {
450502
type: 'line',

0 commit comments

Comments
 (0)