Then, put these into your Kanban’s YAML Frontmatter:
Title: /*(Set anything if you want)*/
kanban-plugin: basic
tag: projects
Total: /*(Metaedit will auto-update these variable)*/
Incomplete:
Completed:
Finally, put code below into your project tracking note:
```dataviewjs
function projectTracker(dv, query) {
let searchPagePaths = dv.pages(query).file.path
for(let i=0; i < searchPagePaths.length; i++){
if(dv.page(searchPagePaths[i]).Total){
let title = dv.page(searchPagePaths[i]).Title;
console
let total = dv.page(searchPagePaths[i]).Total;
let status = ((dv.page(searchPagePaths[i]).Completed / dv.page(searchPagePaths[i]).Total) * 100).toFixed();
const progress = "![pb|500](https://progress-bar.dev/" + status + "/?scale=" + "100" + "&title=" + title + "&width=400)"; //you could set any width if you need
dv.paragraph(progress);
dv.paragraph("<br>"); //use this if you have many projects to track.
}
}
}
projectTracker(
dv,
"#projects" //change tag if you need
)
```
Yep, you did it. You will get something like this below:
@Aonto Help needed. I am trying to do something similar but without Kanban.
I intend have Project > Sub-Project > Sub-Projects.
And have a count auto-updated and a small progressbar on each project page (autoupdated). Possible?
I am not comfortable with using YAML at all, and I initially had a problem with the title - I found that titles with more than one word would break the code. And I see that all your projects are one word.
is there a way to format the YAML Title field with more than one word?
Hi @dryice,
not sure whether you’re still looking for a solution, but I thought I’d post it anyway, as it took me a while to figure out a solution for the same question. I am not a programmer and fairly new to obsidian and dataview. What worked for me though, was to convert the YAML title using encodeURIComponent(). This works for me with YAML titles like “My perfect project”.
function projectTracker(dv, query) {
let searchPagePaths = dv.pages(query).file.path
for(let i=0; i < searchPagePaths.length; i++){
if(dv.page(searchPagePaths[i]).Total){
let title = dv.page(searchPagePaths[i]).Title;
console
let total = dv.page(searchPagePaths[i]).Total;
let status = ((dv.page(searchPagePaths[i]).Completed / dv.page(searchPagePaths[i]).Total) * 100).toFixed();
const progress = "![pb|500](https://progress-bar.dev/" + status + "/?scale=" + "100" + "&title=" + encodeURIComponent(title) + "&width=400)";
dv.paragraph(progress);
// dv.paragraph("<br>");
}
}
}
projectTracker(
dv,
"#projects" //change tag if you need
)
Hi!
really interested on this cause I have a big database with the same problem (2 words or more as a title), but unfortunately, I don’t know how it works this “encodeURIComponent()”. I have put it everywhere and change it many times but I don’t find the way to make it work. Could you give more details about the process? I’d be eternally grateful.
That is so neat! I have now implemented this in my projects.
If you want a quick progress bar for putting directly on an individual project’s page, you can use this, which makes the progress from the un/completed tasks directly on that page:
Hi! The progress-bar server did not renew the domain. I made this adaptation to view it offline. It is still in the development phase. I hope it will be useful to you.