|
190 | 190 | .bar-col { flex: 0 0 32px; } /* fixed width columns prevent overlap and allow scrolling */ |
191 | 191 | .bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; height: 100%; } |
192 | 192 | .bar { width: 100%; max-width: 32px; background: var(--c-primary, #03a9f4); border-radius: 4px 4px 0 0; min-height: 2px; transition: height 0.3s; position: relative; } |
193 | | - .bar:hover::after { |
194 | | - content: attr(data-val); position: absolute; top: -25px; left: 50%; transform: translateX(-50%); |
195 | | - background: var(--card-bg, #1e1e1e); border: 1px solid var(--divider-color, #333); padding: 2px 6px; border-radius: 4px; font-size: 10px; white-space: nowrap; z-index: 10; |
196 | | - } |
197 | 193 | .bar-label { font-size: 0.7rem; color: var(--text-color-muted, #9e9e9e); margin-top: 0.5rem; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; } |
198 | 194 |
|
| 195 | + /* Bar chart tooltip positioned at pointer */ |
| 196 | + .bar-tooltip { |
| 197 | + position: fixed; pointer-events: none; background: var(--card-bg, #1e1e1e); border: 1px solid var(--divider-color, #333); |
| 198 | + padding: 4px 8px; border-radius: 4px; font-size: 11px; white-space: nowrap; z-index: 1000; display: none; |
| 199 | + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); |
| 200 | + } |
| 201 | + .bar-tooltip.visible { display: block; } |
| 202 | + |
199 | 203 | .pie-wrapper { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; gap: 2rem; } |
200 | 204 | .pie-chart { |
201 | 205 | width: 180px; height: 180px; border-radius: 50%; flex-shrink: 0; |
@@ -398,6 +402,9 @@ <h3 class="card-title">Project Breakdown</h3> |
398 | 402 | </div> |
399 | 403 | </div> |
400 | 404 |
|
| 405 | + <!-- Bar chart tooltip positioned at cursor --> |
| 406 | + <div class="bar-tooltip" id="bar-tooltip"></div> |
| 407 | + |
401 | 408 | <script> |
402 | 409 | console.log("[sp-dashboard] Dashboard script initialized"); |
403 | 410 | // --- UTILITIES --- |
@@ -535,6 +542,10 @@ <h3 class="card-title">Project Breakdown</h3> |
535 | 542 | document.getElementById('stat-tasks').innerText = String(metrics.totalCompleted); |
536 | 543 | document.getElementById('stat-tasks-total').innerText = `/ ${metrics.totalTasks} total`; |
537 | 544 |
|
| 545 | + // Progress: completion rate of active tasks in the date range |
| 546 | + // totalCompleted = unique tasks completed |
| 547 | + // totalTasks = unique tasks with either time logged OR completed (note: table shows entries per-day, |
| 548 | + // so one task appearing on multiple days counts as 1 in the denominator) |
538 | 549 | const progress = metrics.totalTasks > 0 ? (metrics.totalCompleted / metrics.totalTasks) * 100 : 0; |
539 | 550 | document.getElementById('stat-tasks-progress').style.width = `${progress}%`; |
540 | 551 |
|
@@ -627,6 +638,31 @@ <h3 class="card-title">Project Breakdown</h3> |
627 | 638 | `; |
628 | 639 | container.appendChild(col); |
629 | 640 | } |
| 641 | + |
| 642 | + // Setup tooltip listeners for bars |
| 643 | + setupBarTooltip(); |
| 644 | + }; |
| 645 | + |
| 646 | + const setupBarTooltip = () => { |
| 647 | + const tooltip = document.getElementById('bar-tooltip'); |
| 648 | + const bars = document.querySelectorAll('.bar-chart .bar'); |
| 649 | + |
| 650 | + bars.forEach(bar => { |
| 651 | + bar.addEventListener('mouseenter', (e) => { |
| 652 | + tooltip.textContent = bar.getAttribute('data-val'); |
| 653 | + tooltip.classList.add('visible'); |
| 654 | + }); |
| 655 | + |
| 656 | + bar.addEventListener('mousemove', (e) => { |
| 657 | + // Position tooltip at cursor with small offset |
| 658 | + tooltip.style.left = (e.clientX + 8) + 'px'; |
| 659 | + tooltip.style.top = (e.clientY - 12) + 'px'; |
| 660 | + }); |
| 661 | + |
| 662 | + bar.addEventListener('mouseleave', () => { |
| 663 | + tooltip.classList.remove('visible'); |
| 664 | + }); |
| 665 | + }); |
630 | 666 | }; |
631 | 667 |
|
632 | 668 | const renderNativePieChart = (projectData, formatFn) => { |
@@ -1041,6 +1077,11 @@ <h3 class="card-title">Project Breakdown</h3> |
1041 | 1077 | { |
1042 | 1078 | id: "t4", parentId: null, title: "Setup Database", isDone: false, projectId: "p1", |
1043 | 1079 | timeSpentOnDay: { [dates[3]]: 10800000 /* 3h */ }, dueDay: "2026-02-18" // Overdue |
| 1080 | + }, |
| 1081 | + { |
| 1082 | + id: "t5", parentId: null, title: "Write Documentation", isDone: false, projectId: "p1", |
| 1083 | + timeSpentOnDay: {}, // No time logged in this period – not included in denominator |
| 1084 | + dueDay: "2026-02-28" // Future due date |
1044 | 1085 | } |
1045 | 1086 | ]; |
1046 | 1087 |
|
|
0 commit comments