Progress bar for notes (Easy and powerful) with dataview

Hi!

Today, I’m going to show you how to track your progress, whether it’s books, notes, projects, goals, or anything else you want to track with a progress bar, with (or without) dataview.


Progress Bar

My example will be with my “currently-reading” book, but like I said it can be anythings you want.

1. Create your note.

2. Add to your metadata the progress code here :

<progress max=100 value=0> </progress> 0%

If you want it more dynamic you can use this code to center it, or put it to the left or right :

<p align = "center"> <progress max=100 value=0> </progress> 0% </p>

Command:

Note Example:

As you can see I named it Progress_Bar (DON’T use spaces in metadata because the dataview will not recognize it, instead use “_” )

Progress Bar + Dataview :

Now I want my reading list to be organized with the dataview so I can track my progress directly in my “Library” note, which brings us to step 3.

3. For the dataview, it’s really easy. Just add the “Progress_Bar” Metadat to the table:

TABLE without id 
  Progress_Bar AS "Progress Bar"

My example:

```dataview
TABLE without id 
  Progress_Bar AS "Progress Bar",
  ("![cover|80](" + Cover + ")") as Cover,
  file.link AS "Title",
  Author AS "Author",
  Category AS "Genre"
FROM #FM/📁02/📖 
where Status = "Currently-reading"
SORT Progress desc
```

Result

That’s it. Thanks for reading and I hope this post helped you in some way.

Feel free to comment if you have any questions, I’m a beginner in coding but I’ll do my best.

P.S: This is my first post, go easy on me :).

30 Likes

Thank you for sharing this! :smile:

Wow, thanks!

Hey, awesome! Currently I’m using this code to create a very similar progress bar:
("![progress + " + (round((Current/TotalPages)*100)) + " %](https://progress-bar.dev/" +(round((Current/TotalPages)*100)) + "/)") AS Progress

Would it somehow be possible to implement this with your version? So it would divide the Current page by the TotalPages to get the percentage?

That way you wouldn’t need to manually put in the percentage.

Thanks :slight_smile:

8 Likes

How would you make this work in a dataviewjs table? I can’t figure out a way to make it work in my dataview js table.

1 Like

Lovely. I take it there is no way to automagically update the plain text when the percentage value has changed?

The progress bar is very huge

1 Like

Here is a minimal example how a dataview query looks like that would automatically render the correct progress bar based on “current” and “total” pages.

TABLE WITHOUT ID
    link(file.link, title) as Title,
    author as Author,
    "<progress max=" + total + " value=" + current + "> </progress> " + round(current/total*100) + "%" as Progress
FROM #book
WHERE status = "reading"

On your book detail page you need this data:

---
tag: book
title: "Super Brain"
author: [Deepak Chopra, Rudolph E. Tanzi]
current: 172
total: 369
status: reading
---

It’s such a cool idea btw, I didn’t know that you could use a <progress> component. I highly recommend the Book Search plugin that automatically creates metadata for a book.

5 Likes

The best answer, thanks very much.

1 Like

Hey! I just started using Obsidian (about two months ago). I would like to ask if somebody knows how to create a progress bar like the one shown by issam-Dev BUT not within a table. I would like to have only the progress bar in my note.

Thanks in advance

Replying to myself, I almost managed to render a progress bar (alone) within the note. However, I would like to change the bar to the one that is displayed by (https://progress-bar.dev/) but I do not how to do it.

The code that I am using is this one:

$= const value = Math.round(((dv.current().file.tasks.where(t => t.completed).length) / (dv.current().file.tasks).length || 0) * 100); "<progress value='" + value + "' max='100'></progress>" + " " + value + "%"

I tried this:

$= const value = "!(https://progress-bar.dev/" + Math.round(((dv.current().file.tasks.where(t => t.completed).length) / (dv.current().file.tasks).length) * 100,0); "<progress value='" + value + "' max='100'></progress>" + " " + value + "%"

But the link is broken.

Please, somebody, help me!

SUCCESS!!!

I did it!! Now I have a very nice progress bar in my note.

$= "![progress](https://progress-bar.dev/" + Math.round(((dv.current().file.tasks.where(t => t.completed).length) / (dv.current().file.tasks).length || 0) * 100) + "/)"

Hey! How did you manage to reduce the size.
I was wondering, how can I increase the length of the bar, when using progess-bar.dev

I used to use MetaEdit to upgrade my completed tasks and modifie my progress value manually. Now, this code will be very useful for me and will help to upgrade my progress bar automatically.

Thank you very much.

1 Like