Vault Activity Heatmap
WIDGETDASHBOARD
maws7140

Vault Activity Heatmap

GitHub-style grid of how many notes you created on each of the last 28 days. Today glows.

What you need

  • The Datacore community plugin (Settings → Community plugins → Browse, search "Datacore").
  • The VaultHub widgets CSS snippet: download vaulthub-widgets.css, save it in your vault's .obsidian/snippets/ folder, then switch it on under Settings → Appearance → CSS snippets. One snippet styles every VaultHub widget.

Add it to a note

Paste the block below into any note. It renders in Live Preview and Reading view.

Each square is one day, oldest at the top left and today at the bottom right. Darker purple means more notes created that day, scaled to your busiest day. Change DAYS to show a longer or shorter window.

return function ActivityHeatmap() {
    const DAYS = 28;
    const pages = dc.useQuery("@page") || [];

    const today = new Date();
    today.setHours(0, 0, 0, 0);
    const counts = new Array(DAYS).fill(0);
    for (const page of pages) {
        const created = new Date(page.$ctime);
        created.setHours(0, 0, 0, 0);
        const daysAgo = Math.round((today - created) / 86400000);
        if (daysAgo >= 0 && daysAgo < DAYS) counts[DAYS - 1 - daysAgo] += 1;
    }
    const busiest = Math.max(1, ...counts);
    const level = (n) => (n === 0 ? '' : 'l' + Math.min(4, Math.ceil((n / busiest) * 4)));
    const total = counts.reduce((a, b) => a + b, 0);

    return (
        <div className="vh-widget vh-heatmap">
            <div className="vh-hm-header">
                <span>NOTES CREATED</span>
                <span>{total} IN {DAYS} DAYS</span>
            </div>
            <div className="vh-hm-grid">
                {counts.map((n, i) => (
                    <div
                        key={i}
                        className={`vh-hm-cell ${i === DAYS - 1 ? 'active' : level(n)}`}
                        title={`${n} note${n === 1 ? '' : 's'}`}
                    />
                ))}
            </div>
        </div>
    );
}

Related

How to Install

  1. Install the Datacore community plugin
  2. Add the VaultHub widgets CSS snippet to .obsidian/snippets/ and enable it
  3. Copy the code block on this page into any note

Required Plugins

Datacore

Tags

vaulthubheatmapactivitystreak