Hello! I’m trying to use a graph (adapted from something I found online) to compare patterns in my daily notes using DataviewJS and Charts plugin. The basic setup works fine with inline Dataview tags, but I’m having trouble when trying to use tags in frontmatter.
Here’s the code I’m working with:
const rawData = await dv.query('TABLE file.name, Data1, contains(Tags, "#-Data2"), contains(Tags, "#-Data3") FROM "Daily-notes" and #Tags SORT file.name') ;
const rows = rawData.value.values;
const chartData = {
type: 'line',
data: {
labels: rows.map(x => x[1]),
datasets: [
{label: 'Data1', data: rows.map(x => x[2])},
{label: '-Data2', data: rows.map(x => x[3])},
{label: '-Data3', data: rows.map(x => x[4])},
],
},
}
window.renderChart(chartData, this.container);
Data1 is a numerical value between 1-5 and ignores null values. -Data2 and -Data3 are tags that are plotted as 0 or 1 depending on their presence. It works perfectly when using inline Dataview tags in the format #Tags:: #-Data1 etc but I need it to work with frontmatter tags like:
tags:
- -Data1
- -Data2
I’ve scoured resources online but I’m out of ideas and out of my depth. If anyone has any idea it’d be much appreciated! Thanks