Make ProgressBar from MetaData using Variables from same file

Things I have tried

Make Progress Bar from MetaData using Variables from same file.
I want to use Progress and Target and divide to get the value of progress.

I have tried this.Progress and dv.current().Progress but both didn’t work.

Progress get the correct number of objects and so does Target but Progress_Bar return NaN with empty progress bar.

What I’m trying to do

%%
Pillars:: [[Learning|Learning]]
Progress:: `$= dv.page("2022-07-14 - German").file.inlinks.where(p => {const mp = dv.page(p.path); return mp.tags?.contains("Objective") && mp.status === 'Completed'}).length`
Target:: `$= dv.page("2022-07-14 - German").file.inlinks.where(p => {const mp = dv.page(p.path); return mp.tags?.contains("Objective")}).length`
Progress_Bar:: `$= "<progress value='" + (this.Progress / this.Target) * 100 + "' max='100'></progress>" + " " + (dv.current().Progress / dv.current().Target) * 100 + "%"`
Objectives:: `$= const objectives = dv.page('2022-07-14 - German').file.inlinks.where(p => { const mp = dv.page(p.path); return mp.tags?.contains('Objective') && mp.status === 'In Progress'}); if (objectives.length > 0) { dv.header(4, objectives.length > 1 ? "Objectives" : "Objectives"); dv.list(objectives) }`
2 Likes

If you just output the value for dv.current().Progress (or target) in your progress bar line do you get anything? I am wondering if there is some timing issue, where it cannot see the actual value for Progress and Target because it is trying to fill everything out at the same time. Not sure how to fix if that is the case - might be a good question for the dataview GitHub discussions page.

I just double-checked, No, I don’t get anything. That timing issue you mentioned makes sense. I think it’s the situation here. Will check dataview GitHub discussion page.

1 Like