Skip to content

Commit 0661e95

Browse files
Update dashboard.html
1 parent 8eb3f4d commit 0661e95

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

templates/dashboard.html

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ <h3>
144144
}
145145

146146
#categoryDonutChart {
147-
max-width: 90%;
147+
max-width: 100%;
148+
max-height: 100%;
148149
}
149150

150151
.chart-title {
@@ -353,6 +354,25 @@ <h3>
353354
},
354355
tooltip: {
355356
displayColors: false, // Remove colored squares
357+
enabled: false,
358+
external: function(context) {
359+
let tooltipEl = document.getElementById('chartjs-tooltip');
360+
if (!tooltipEl) {
361+
tooltipEl = document.createElement('div');
362+
tooltipEl.id = 'chartjs-tooltip';
363+
tooltipEl.style.cssText = 'position:fixed;background:rgba(0,0,0,0.75);color:#fff;padding:6px 10px;border-radius:6px;font-size:12px;pointer-events:none;z-index:9999;white-space:nowrap;transition:opacity 0.1s;';
364+
document.body.appendChild(tooltipEl);
365+
}
366+
const tooltipModel = context.tooltip;
367+
if (tooltipModel.opacity === 0) {
368+
tooltipEl.style.opacity = '0';
369+
return;
370+
}
371+
if (tooltipModel.body) {
372+
tooltipEl.innerHTML = tooltipModel.body.map(b => b.lines).join('<br>');
373+
}
374+
tooltipEl.style.opacity = '1';
375+
},
356376
callbacks: {
357377
title: function() {
358378
return ''; // Remove title (was showing "Worth" or "Ounces")
@@ -498,6 +518,21 @@ <h3>
498518
}
499519
});
500520

521+
// Track mouse position for external tooltip
522+
document.querySelectorAll('#valueChart, #metalsValueChart').forEach(canvas => {
523+
canvas.addEventListener('mousemove', function(e) {
524+
const tooltipEl = document.getElementById('chartjs-tooltip');
525+
if (tooltipEl && tooltipEl.style.opacity !== '0') {
526+
tooltipEl.style.left = (e.clientX + 12) + 'px';
527+
tooltipEl.style.top = (e.clientY - 28) + 'px';
528+
}
529+
});
530+
canvas.addEventListener('mouseleave', function() {
531+
const tooltipEl = document.getElementById('chartjs-tooltip');
532+
if (tooltipEl) tooltipEl.style.opacity = '0';
533+
});
534+
});
535+
501536
// Category Breakdown Donut Chart
502537
const categoryDonutCtx = document.getElementById('categoryDonutChart').getContext('2d');
503538

@@ -535,7 +570,7 @@ <h3>
535570
options: {
536571
responsive: true,
537572
maintainAspectRatio: true,
538-
aspectRatio: 2,
573+
aspectRatio: 1,
539574
plugins: {
540575
legend: {
541576
display: false // Remove legend

0 commit comments

Comments
 (0)