var pages = dv.pages('#daily');
pages = pages.filter(p => p.file.name.includes('<% tp.date.now('YYYY-MM', 0, tp.file.title, 'YYYY-MM') %>'));
var titles = [], weights = [], eatingWindows = [];
pages.sort().forEach(p => {
titles.push(p.file.name);
weights.push(p.weight || 0);
eatingWindows.push([p.startEating, p.endEating]);
});
const chartData = {
type: 'bar',
data: {
labels: titles,
datasets: [{
yAxisID: 'A',
label: 'Weight (lbs)',
data: weights,
backgroundColor: [
'rgba(255, 99, 132, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)'
],
borderWidth: 1,
fill: true,
time: 'day'
},
{
yAxisID: 'B',
type: 'bar',
label: 'Eating Window',
data: eatingWindows,
backgroundColor: [
'rgba(153, 102, 255, 0.2)'
],
borderColor: [
'rgba(153, 102, 255, 1)'
],
borderWidth: 1,
},
{
yAxisID: 'B',
type: 'line',
data: eatingWindows.map(w => 12),
pointRadius: 0,
borderColor: [
'rgba(153, 102, 255, 1)'
],
borderWidth: 0.5,
borderDash: [4,40]
},
{
yAxisID: 'B',
type: 'line',
data: eatingWindows.map(w => 20),
pointRadius: 0,
borderColor: [
'rgba(153, 102, 255, 1)'
],
borderWidth: 0.5,
borderDash: [4,40]
}]
},
options: {
scales: {
A: {
min: 190,
max: 210
},
B: {
position: 'right',
max: 22,
min: 8,
ticks: {
count: 15
}
},
x: {
type: 'time',
time: {
unit: 'day'
},
ticks: {
maxRotation: 90,
minRotation: 90
}
}
}
}
}
window.renderChart(chartData, this.container);
Created
February 17, 2024 19:48
-
-
Save jakeweidokal/a95db67753eeee3d8cc48e6eb5547dc7 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment