|
144 | 144 | } |
145 | 145 |
|
146 | 146 | #categoryDonutChart { |
147 | | - max-width: 90%; |
| 147 | + max-width: 100%; |
| 148 | + max-height: 100%; |
148 | 149 | } |
149 | 150 |
|
150 | 151 | .chart-title { |
@@ -353,6 +354,25 @@ <h3> |
353 | 354 | }, |
354 | 355 | tooltip: { |
355 | 356 | 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 | + }, |
356 | 376 | callbacks: { |
357 | 377 | title: function() { |
358 | 378 | return ''; // Remove title (was showing "Worth" or "Ounces") |
@@ -498,6 +518,21 @@ <h3> |
498 | 518 | } |
499 | 519 | }); |
500 | 520 |
|
| 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 | + |
501 | 536 | // Category Breakdown Donut Chart |
502 | 537 | const categoryDonutCtx = document.getElementById('categoryDonutChart').getContext('2d'); |
503 | 538 |
|
|
535 | 570 | options: { |
536 | 571 | responsive: true, |
537 | 572 | maintainAspectRatio: true, |
538 | | - aspectRatio: 2, |
| 573 | + aspectRatio: 1, |
539 | 574 | plugins: { |
540 | 575 | legend: { |
541 | 576 | display: false // Remove legend |
|
0 commit comments