day separators at anchor hour (23:00), only in week view
This commit is contained in:
1 parent
75b324e388
commit
0c5f211f1c
2 files changed
+15
-6
No files matched your search
+13
-5
@@ -4,8 +4,7 @@ const ZOOM_LEVELS = [
|
||||
{ name: '1 Monat', weeks: 4 },
|
||||
{ name: '2 Wochen', weeks: 2 },
|
||||
{ name: '1 Woche', weeks: 1 },
|
||||
{ name: '1 Tag', days: 1 },
|
||||
{ name: '12 Stunden', days: 0.5 },
|
||||
{ name: '1 Tag', days: 1 }
|
||||
];
|
||||
const WEEKLY_BUDGET = 500; // $ pro Woche
|
||||
|
||||
@@ -158,6 +157,7 @@ function renderBucketChart(buckets, bucketMinutes) {
|
||||
|
||||
// Determine week boundaries for grouping
|
||||
let lastWeekId = null;
|
||||
let lastDayId = null;
|
||||
|
||||
for (let i = 0; i < BAR_COUNT; i++) {
|
||||
const b = bucketMap[i];
|
||||
@@ -168,16 +168,24 @@ function renderBucketChart(buckets, bucketMinutes) {
|
||||
const bucketStart = new Date(viewFrom.getTime() + i * bucketMinutes * 60000);
|
||||
const bucketEnd = new Date(viewFrom.getTime() + (i + 1) * bucketMinutes * 60000);
|
||||
|
||||
// Check if this bucket crosses into a new week
|
||||
// Check if this bucket crosses into a new week or day
|
||||
const weekAnchor = getLastAnchor(bucketStart);
|
||||
const weekId = weekAnchor.getTime();
|
||||
if (lastWeekId !== null && weekId !== lastWeekId) {
|
||||
// Use local time for day boundary at anchor hour
|
||||
const localDayStart = new Date(bucketStart);
|
||||
localDayStart.setHours(localDayStart.getHours() - ANCHOR_HOUR);
|
||||
const dayId = localDayStart.toLocaleDateString();
|
||||
const isNewWeek = lastWeekId !== null && weekId !== lastWeekId;
|
||||
const showDaySep = ZOOM_LEVELS[zoomIndex].weeks === 1;
|
||||
const isNewDay = showDaySep && lastDayId !== null && dayId !== lastDayId && !isNewWeek;
|
||||
if (isNewWeek || isNewDay) {
|
||||
const spacer = document.createElement('div');
|
||||
spacer.className = 'bar-spacer';
|
||||
spacer.className = isNewWeek ? 'bar-spacer' : 'bar-spacer day-spacer';
|
||||
chart.appendChild(spacer);
|
||||
labels.appendChild(Object.assign(document.createElement('div'), { className: 'chart-label bar-spacer' }));
|
||||
}
|
||||
lastWeekId = weekId;
|
||||
lastDayId = dayId;
|
||||
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.className = 'bar-wrapper';
|
||||
|
||||
Reference in new issue
Block a user