Open Lucifer-Clegg opened 3 months ago
sample
const data = dv.pages('#project')
.filter(p => p.modified)
// core, we should flatmap modified values, because modified property is list
.flatMap(p => {
return p.modified.map(t => {
return {
time: t,
page: p
}
})
})
.groupBy(p => p.time.toFormat('yyyy-MM-dd'))
.map(entry =>{
return {
date: entry.key,
value: entry.rows.length
}
})
const calendarData = {
data: data,
days: 365
}
renderContributionGraph(this.container, calendarData)
thank you for your reply,
unfortunately I get an error:
Evaluation Error: TypeError: p.modified.map is not a function
thank you for your reply, unfortunately I get an error:
Evaluation Error: TypeError: p.modified.map is not a function
maybe some modified
property's value is not list?
try to fixed
const data = dv
.pages("")
.filter((p) => p.modified)
// core, we should flatmap modified values, because modified property is list
.flatMap((p) => {
if (!Array.isArray(p.modified)) {
return [{
time: p.modified,
page: p
}]
}
return p.modified.map((t) => {
return {
time: t,
page: p,
};
});
})
.groupBy((p) => p.time.toFormat("yyyy-MM-dd"))
.map((entry) => {
return {
date: entry.key,
value: entry.rows.length,
};
});
const calendarData = {
data: data,
days: 365,
};
renderContributionGraph(this.container, calendarData);
thank you very much, but I set only one file in
const data = dv.pages("[[test_file]]")
these are the entries of the file in modified
:
---
PrState: 4
modified:
- 2024-07-06T15:38:34
- 2024-07-07T15:38:34
- 2024-07-07T16:48:34
- 2024-07-08T17:20:34
- 2024-07-08T20:38:34
- 2024-07-09T21:52:34
- 2024-07-10T14:02:18
- 2024-07-10T14:02:18
- 2024-07-10T15:56:32
- 2024-07-11T13:34:26
- 2024-07-12T13:56:49
layoutDone: 1
---
but with this
if (!Array.isArray...
it works.
Hi, how do I have to change the DVJS code if I have a multi value field
modified
in frontmatter (properties) and I want to display the changes of this file?so the values are like this:
and when I set:
.groupBy(p => p.modified.toFormat('yyyy-MM-dd'))
I get :Evaluation Error: TypeError: p.modified.toFormat is not a function