Skip to content

Commit 3695196

Browse files
committed
feat: add tag usage pie chart component and statistics utility for enhanced session tracking
1 parent a2ad32d commit 3695196

File tree

4 files changed

+414
-0
lines changed

4 files changed

+414
-0
lines changed

src/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,22 @@ <h3>Focus Weekly Summary</h3>
254254
</div>
255255
</div>
256256

257+
<!-- Tag Usage Pie Chart -->
258+
<div class="tag-usage-card">
259+
<h3>Tag Usage This Week</h3>
260+
<div class="tag-chart-container">
261+
<div class="tag-pie-chart" id="tag-pie-chart">
262+
<div class="pie-chart-placeholder">
263+
<i class="ri-pie-chart-line"></i>
264+
<span>No data available</span>
265+
</div>
266+
</div>
267+
<div class="tag-legend" id="tag-legend">
268+
<!-- Legend items will be populated by JavaScript -->
269+
</div>
270+
</div>
271+
</div>
272+
257273
<!-- Weekly Sessions Chart -->
258274
<div class="weekly-chart-card">
259275
<h3>This Week's Sessions</h3>

src/managers/navigation-manager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// Navigation Manager for Sidebar
22
import { TimeUtils } from '../utils/common-utils.js';
3+
import { TagStatistics } from '../utils/tag-statistics.js';
34

45
export class NavigationManager {
56
constructor() {
67
this.currentView = 'timer';
78
this.initialized = false;
89
this.currentTooltip = null; // Track current tooltip for proper cleanup
910
this.tooltipTimeout = null; // Track timeout for debounced tooltip removal
11+
this.tagStatistics = new TagStatistics(); // Initialize tag statistics utility
1012

1113
// Apply timer-active class on initial load since default view is timer
1214
document.body.classList.add('timer-active');
@@ -84,6 +86,7 @@ export class NavigationManager {
8486
await this.updateFocusSummary();
8587
await this.updateWeeklySessionsChart();
8688
this.updateDailyChart();
89+
await this.updateTagUsageChart(); // Update tag usage pie chart
8790
await this.updateSelectedDayDetails();
8891
await this.initSessionsTable(); // Initialize sessions table when viewing calendar
8992
} else if (view === 'settings') {

src/styles/statistics.css

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,173 @@
136136
.focus-metric .metric-change.negative {
137137
color: var(--focus-color) !important;
138138
background: color-mix(in srgb, var(--focus-color) 10%, transparent) !important;
139+
}
140+
141+
/* Tag Usage Pie Chart Styles */
142+
.tag-usage-card {
143+
background: white;
144+
border-radius: 12px;
145+
padding: 24px;
146+
margin-bottom: 24px;
147+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
148+
border: 1px solid #e5e7eb;
149+
}
150+
151+
.tag-usage-card h3 {
152+
margin: 0 0 20px 0;
153+
color: #374151;
154+
font-size: 1.1rem;
155+
font-weight: 600;
156+
}
157+
158+
.tag-chart-container {
159+
display: flex;
160+
align-items: center;
161+
gap: 24px;
162+
min-height: 200px;
163+
}
164+
165+
.tag-pie-chart {
166+
position: relative;
167+
width: 200px;
168+
height: 200px;
169+
border-radius: 50%;
170+
flex-shrink: 0;
171+
}
172+
173+
.pie-chart-placeholder {
174+
display: flex;
175+
flex-direction: column;
176+
align-items: center;
177+
justify-content: center;
178+
width: 100%;
179+
height: 100%;
180+
color: #9ca3af;
181+
border: 2px dashed #d1d5db;
182+
border-radius: 50%;
183+
}
184+
185+
.pie-chart-placeholder i {
186+
font-size: 48px;
187+
margin-bottom: 8px;
188+
}
189+
190+
.pie-chart-placeholder span {
191+
font-size: 14px;
192+
text-align: center;
193+
}
194+
195+
.tag-legend {
196+
flex: 1;
197+
display: flex;
198+
flex-direction: column;
199+
gap: 12px;
200+
}
201+
202+
.tag-legend-item {
203+
display: flex;
204+
align-items: center;
205+
gap: 12px;
206+
}
207+
208+
.tag-legend-color {
209+
width: 16px;
210+
height: 16px;
211+
border-radius: 4px;
212+
flex-shrink: 0;
213+
}
214+
215+
.tag-legend-info {
216+
flex: 1;
217+
}
218+
219+
.tag-legend-name {
220+
font-weight: 500;
221+
color: #374151;
222+
font-size: 14px;
223+
}
224+
225+
.tag-legend-stats {
226+
display: flex;
227+
align-items: center;
228+
gap: 8px;
229+
margin-top: 2px;
230+
}
231+
232+
.tag-legend-time {
233+
color: #6b7280;
234+
font-size: 13px;
235+
}
236+
237+
.tag-legend-percent {
238+
color: #9ca3af;
239+
font-size: 12px;
240+
font-weight: 500;
241+
}
242+
243+
/* Pie chart segments */
244+
.pie-segment {
245+
position: absolute;
246+
width: 100%;
247+
height: 100%;
248+
border-radius: 50%;
249+
clip-path: polygon(50% 50%, 50% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, 50% 0%);
250+
}
251+
252+
/* Dark theme styles for tag usage chart */
253+
[data-theme="dark"] .tag-usage-card {
254+
background: #1e293b;
255+
border-color: #334155;
256+
color: #f1f5f9;
257+
}
258+
259+
[data-theme="dark"] .tag-usage-card h3 {
260+
color: #f1f5f9;
261+
}
262+
263+
[data-theme="dark"] .pie-chart-placeholder {
264+
color: #64748b;
265+
border-color: #475569;
266+
}
267+
268+
[data-theme="dark"] .tag-legend-name {
269+
color: #f1f5f9;
270+
}
271+
272+
[data-theme="dark"] .tag-legend-time {
273+
color: #94a3b8;
274+
}
275+
276+
[data-theme="dark"] .tag-legend-percent {
277+
color: #64748b;
278+
}
279+
280+
/* Auto theme dark styles for tag usage chart */
281+
@media (prefers-color-scheme: dark) {
282+
[data-theme="auto"] .tag-usage-card {
283+
background: #1e293b;
284+
border-color: #334155;
285+
color: #f1f5f9;
286+
}
287+
288+
[data-theme="auto"] .tag-usage-card h3 {
289+
color: #f1f5f9;
290+
}
291+
292+
[data-theme="auto"] .pie-chart-placeholder {
293+
color: #64748b;
294+
border-color: #475569;
295+
}
296+
297+
[data-theme="auto"] .tag-legend-name {
298+
color: #f1f5f9;
299+
}
300+
301+
[data-theme="auto"] .tag-legend-time {
302+
color: #94a3b8;
303+
}
304+
305+
[data-theme="auto"] .tag-legend-percent {
306+
color: #64748b;
307+
}
139308
}

0 commit comments

Comments
 (0)