Skip to content

Commit 86a71c8

Browse files
fix(sunburst-clock): respect startOfDay offset when rendering the clock (#766)
* fix(sunburst-clock): respect startOfDay offset when rendering the clock The sunburst clock was ignoring the user's "Start of day" setting and always using calendar midnight (00:00) as the start of the visualization window. This meant the queried time range (e.g. 04:00-04:00 next day) didn't align with the clock's visual range (00:00-23:59), causing events between midnight and the startOfDay offset to appear missing. Pass the starttime (already offset-aware) from SunburstClock.vue into sunburst-clock.ts so both the data query and the visualization use the same 24h window. Also adjust the clock tick labels to be placed at 6-hour intervals relative to the actual start-of-day hour rather than hard-coded at 0/6/12/18. Fixes #358 * fix(sunburst-clock): use standard clock ticks with special start-of-day marker Keep 6-hour ticks at standard positions (00:00, 06:00, 12:00, 18:00) for analog-clock familiarity. Add a special ☀ marker for the start-of-day boundary when it differs from midnight (e.g. 04:00 ☀ for the default setting).
1 parent 934daca commit 86a71c8

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

src/visualizations/SunburstClock.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export default {
219219
};
220220
this.centerMsg = 'No data';
221221
}
222-
sunburst.update(this.$el, hierarchy);
222+
sunburst.update(this.$el, hierarchy, this.starttime);
223223
});
224224
});
225225
},

src/visualizations/sunburst-clock.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ function create(el: HTMLElement) {
232232
}
233233

234234
// Main function to draw and set up the visualization, once we have the data.
235-
function update(el: HTMLElement, root_event: IEvent & { children: IEvent[] }) {
235+
function update(
236+
el: HTMLElement,
237+
root_event: IEvent & { children: IEvent[] },
238+
startOfDay?: moment.Moment
239+
) {
236240
// Basic setup of page elements.
237241
initializeBreadcrumbTrail();
238242

@@ -255,13 +259,27 @@ function update(el: HTMLElement, root_event: IEvent & { children: IEvent[] }) {
255259
let root_start = moment(root_event.timestamp);
256260
let root_end = root_start.clone().add(root_event.duration, 'seconds');
257261
if (show_whole_day) {
258-
root_start = root_start.startOf('day');
259-
root_end = root_start.clone().endOf('day');
260-
261-
drawClock(0, 0);
262-
drawClock(6, 0);
263-
drawClock(12, 0);
264-
drawClock(18, 0);
262+
// Use the provided start-of-day (which respects the user's startOfDay setting)
263+
// so that events between midnight and the startOfDay offset are shown correctly.
264+
// Fall back to calendar midnight if no startOfDay is provided.
265+
if (startOfDay) {
266+
root_start = startOfDay.clone();
267+
} else {
268+
root_start = root_start.startOf('day');
269+
}
270+
root_end = root_start.clone().add(1, 'days');
271+
272+
// Draw clock ticks at standard 6-hour intervals (00, 06, 12, 18)
273+
for (const h of [0, 6, 12, 18]) {
274+
drawClock(h, 0);
275+
}
276+
277+
// Draw a special marker for the start-of-day boundary if it's not at midnight
278+
const start_hour = root_start.hours();
279+
const start_min = root_start.minutes();
280+
if (start_hour !== 0 || start_min !== 0) {
281+
drawClock(start_hour, start_min, `${root_start.format('HH:mm')} ☀`);
282+
}
265283

266284
// TODO: Draw only if showing today
267285
const now = moment();

0 commit comments

Comments
 (0)