🧠 공부 계획
🌱 평안
const today = moment();
const oneWeekAgo = moment().subtract(6, 'days');
const pages = dv.pages('"Daily"')
.where(p => {
const date = moment(p.file.name, 'MM-DD, ddd');
return date.isBetween(oneWeekAgo, today, 'day', '[]');
})
.sort(p => p.file.name);
const labels = pages.map(p => p.file.name);
const studyData = [];
const personalData = [];
for (let page of pages) {
let studyCount = 0;
let personalCount = 0;
for (let task of page.file.tasks) {
if (task.completed) {
if (task.text.includes("#공부")) studyCount++;
if (task.text.includes("#평안")) personalCount++;
}
}
studyData.push(studyCount);
personalData.push(personalCount);
}
const chartData = {
type: 'bar',
data: {
labels: labels,
datasets: [
{
label: '공부',
data: studyData,
backgroundColor: 'rgba(54, 162, 235, 0.7)',
stack: 'Stack 0'
},
{
label: '평안',
data: personalData,
backgroundColor: 'rgba(255, 206, 86, 0.7)',
stack: 'Stack 0'
}
]
},
options: {
responsive: true,
plugins: {
legend: {
labels: {
color: 'white' // 범례 텍스트 색상
}
},
title: {
display: true,
text: '간단·명료해야 본질이다',
color: 'white', // 제목 텍스트 색상 (중요!)
font: {
size: 18
}
}
},
scales: {
x: {
stacked: true,
grid: {
color: 'white' // x축 격자선 색상
},
ticks: {
color: 'white' // x축 눈금 텍스트 색상
}
},
y: {
stacked: true,
beginAtZero: true,
grid: {
color: 'white' // y축 격자선 색상
},
ticks: {
color: 'white' // y축 눈금 텍스트 색상
}
}
}
}
};
window.renderChart(chartData, this.container);
The code above is how I used the tasks, dataview, and charts plugins in Obsidian to create a bar graph of daily tasks by category, but I found it cumbersome to tag each task to categorize them. It would be nice if it could automatically recognize the categories from the headings, but it's only theoretically possible and doesn't work with the actual dataviewjs syntax.
The way it is now, dataviewjs calls the charts plugin, but I was wondering if it would be possible to create a 'table' of tasks by category via the dataview or tasks plugin, and then have dataviewjs or charts recognize that table and convert it into a bar graph? I don't want to know if it's theoretically possible, I want to know if it's 'realistically' possible based on how dataviewjs and charts are actually driven. Please answer by referring to posts on reddit, obsidian community forum, and github. Answer in Korean.