Highlight weekend days in dashboard activity chart
Add isoDow() helper to datetime.js and mark weekend columns in the 14-day activity chart on the dashboard (orange bar, muted day label).
This commit is contained in:
@@ -39,12 +39,13 @@ function renderActivity(activity) {
|
||||
const map = {};
|
||||
activity.forEach(a => { map[a.d] = a.n; });
|
||||
const days = last14days().map(iso => {
|
||||
return { iso, label: fmtDayMonthIso(iso), n: map[iso] || 0 };
|
||||
const dow = typeof isoDow === 'function' ? isoDow(iso) : -1;
|
||||
return { iso, label: fmtDayMonthIso(iso), n: map[iso] || 0, weekend: dow === 0 || dow === 6 };
|
||||
});
|
||||
const max = Math.max(1, ...days.map(x => x.n));
|
||||
const todayKey = todayIso();
|
||||
document.getElementById('activityChart').innerHTML = days.map(x => `
|
||||
<div class="bar-col" title="${x.iso} — ${x.n} ${plural(x.n, 'запись', 'записи', 'записей')}">
|
||||
<div class="bar-col ${x.weekend ? 'weekend' : ''}" title="${x.iso} — ${x.n} ${plural(x.n, 'запись', 'записи', 'записей')}">
|
||||
<div class="bar ${x.iso === todayKey ? 'today' : ''}" style="height:${Math.round(x.n / max * 100)}%"></div>
|
||||
<div class="bar-day">${x.label}</div>
|
||||
</div>`).join('');
|
||||
|
||||
Reference in New Issue
Block a user