Skip to content

adamhl8/dataviewjs-habit-tracker

Repository files navigation

dataviewjs-habit-tracker

This is a code snippet for the Obsidian plugin Dataview. This generates a table that tracks habit completions over the past week. No Dataview annotations required!

Issues/PRs are welcome and encouraged.

Example

## Habits
- [ ] Exercise
- [ ] Read
- [ ] Study
- [ ] New Habit

<dataviewjs code block here>

Get snippet code here.

  • It automatically creates table headers based on unique task names (no duplicates).
  • This means you don't need to define any specific Dataview annotations. Just normal tasks.
  • If a task didn't exist previously (or no longer exists), you'll see a "➖" for its status. Otherwise, "✔" for complete and "❌" for incomplete.

Setup

If the table does not show up right away, try restarting Obsidian.

This assumes you're using the built-in Daily notes plugin.

  • In your daily notes template, add habits (as tasks) under a header named "Habits".
  • Paste the dataviewjs snippet in a dataviewjs code block in your template.
```dataviewjs
<code here>
```
  • Create daily notes using a "YYYY-MM-DD" naming scheme. e.g. 2022-07-31
  • Place daily notes in a folder called "Daily Notes".
    • To use a different folder name, change the .pages('"Daily Notes"') line in the code.