Obsidian_-
NOTE
syh667

Obsidian_-

一个基于日记文件自动生成日程热力图、周统计柱形图、累计折线图、未来日程星标的 Obsidian DataviewJS 模板代码。 / An Obsidian DataviewJS template code that automatically generates a schedule heatmap, weekly statistical bar chart, cumulative line chart, and future schedule star markers based on daily note files.

一个用于 Obsidian 的 DataviewJS 日记活动热力图模板。

它会扫描仓库中命名为 YYYY-MM-DD.md 的每日笔记,并生成:

  • 每日日历热力图
  • 每周日记数量柱形图
  • 年内累计字数折线图
  • 年份下拉切换
  • 未来日程五角星标记

预览

image image image

功能

  • 默认扫描整个 Obsidian 仓库,不要求用户创建固定的日记文件夹。
  • 只统计文件名符合 YYYY-MM-DD.md 的笔记。
  • 点击任意日期会打开对应日记;如果不存在,Obsidian 会创建该笔记。
  • 未来日期如果已有非空日记,会显示为空心五角星 ☆,表示未来日程。
  • 自动包含当前年份和下一年份。
  • 历史年份会根据已有日记自动出现在年份菜单中。

依赖

需要安装并启用 Obsidian 社区插件:

并在 Dataview 设置中开启:

Enable JavaScript queries

使用方法

  1. 打开你的 Obsidian 仓库。
  2. 安装并启用 Dataview。
  3. 复制 examples/Obsidian Diary Heatmap Template.md 中的内容到你指定笔记中的指定位置。
  4. 切换到阅读模式查看。

日记命名规则

默认识别这种文件名:

2026-08-23.md
2026-08-24.md
2027-01-01.md

文件可以放在仓库根目录,也可以放在任意文件夹中。

例如以下都会被识别:

2026-08-23.md
日记/2026-08-23.md
Daily Notes/2026-08-23.md
Journal/2026-08-23.md

指定日记文件夹

模板默认全库扫描:

const diaryFolder = "";

如果你只想统计某个文件夹,可以改成:

const diaryFolder = "日记";

或:

const diaryFolder = "Daily Notes";

此时点击日期会在该文件夹下打开或创建日记。

颜色规则

每日热力图根据当天日记正文长度显示颜色:

0 字          灰色
1-199 字      深蓝
200-799 字    蓝色
800-1599 字   亮蓝
1600 字以上   最亮

Frontmatter 不计入正文长度。

许可证

MIT License

How to Install

  1. Download the template file from GitHub
  2. Move it anywhere in your vault (or your sidebar notes)
  3. Open it in Obsidian — done!

Stats

Stars

1

Forks

0

License

MIT

Last updated 1mo ago