Skip to content

Recipe: Reading Tracker

Visualize your reading progress with a bar chart.

The Result

A bar chart showing books read per month, colored by genre.

Option 1: Inline Data

Quick start - paste this and modify the data:

markdown
```dg
type: bar
data:
  source: '[
    {"month": "Jan", "books": 3, "genre": "Fiction"},
    {"month": "Jan", "books": 1, "genre": "Non-Fiction"},
    {"month": "Feb", "books": 2, "genre": "Fiction"},
    {"month": "Feb", "books": 2, "genre": "Non-Fiction"},
    {"month": "Mar", "books": 4, "genre": "Fiction"},
    {"month": "Mar", "books": 1, "genre": "Non-Fiction"}
  ]'
x: month
y: books
color: genre
title: Books Read in 2024
```

Option 2: From a CSV File

Create data/reading-log.csv:

csv
month,books,genre,pages
Jan,3,Fiction,890
Jan,1,Non-Fiction,320
Feb,2,Fiction,540
Feb,2,Non-Fiction,480
Mar,4,Fiction,1200
Mar,1,Non-Fiction,280

Then use:

markdown
```dg
type: bar
data:
  file: data/reading-log.csv
x: month
y: books
color: genre
title: Books Read in 2024
```

Option 3: From Your Vault

If you track books as notes with frontmatter:

yaml
---
type: book
finished: 2024-01-15
genre: Fiction
pages: 342
---

Query them:

markdown
```dg
type: bar
data:
  query: from:Books where:type:book
transformations:
  - type: aggregate
    configuration:
      groupBy: ["genre"]
      count: ["title"]
x: genre
y: title_count
title: Books by Genre
```

Customizations

Show total pages instead of book count:

yaml
y: pages

Stack genres:

yaml
stack: true

Horizontal bars:

yaml
horizontal: true

Different colors:

yaml
scales:
  color:
    scheme: "paired"

Released under the MIT License.