Split intervals

This commit is contained in:
jude
2023-06-21 15:24:43 +01:00
parent 3d627b5bf0
commit 284bfcd9ad
4 changed files with 93 additions and 17 deletions

View File

@ -7,13 +7,18 @@ document.addEventListener("DOMContentLoaded", () => {
new Chart(document.getElementById("schedule"), {
type: "bar",
data: {
labels: data.schedule.map((row) =>
luxon.DateTime.fromISO(row.time_key)
),
labels: [
...data.scheduleShort.once,
...data.scheduleShort.interval,
].map((row) => luxon.DateTime.fromISO(row.time_key)),
datasets: [
{
label: "Reminders",
data: data.schedule.map((row) => row.count),
data: data.scheduleShort.once.map((row) => row.count),
},
{
label: "Intervals",
data: data.scheduleShort.interval.map((row) => row.count),
},
],
},
@ -22,11 +27,15 @@ document.addEventListener("DOMContentLoaded", () => {
maintainAspectRatio: false,
scales: {
x: {
stacked: true,
type: "time",
time: {
unit: "minute",
},
},
y: {
stacked: true,
},
},
},
});
@ -34,13 +43,18 @@ document.addEventListener("DOMContentLoaded", () => {
new Chart(document.getElementById("scheduleLong"), {
type: "bar",
data: {
labels: data.scheduleLong.map((row) =>
luxon.DateTime.fromISO(row.time_key)
),
labels: [
...data.scheduleLong.once,
...data.scheduleLong.interval,
].map((row) => luxon.DateTime.fromISO(row.time_key)),
datasets: [
{
label: "Reminders",
data: data.scheduleLong.map((row) => row.count),
data: data.scheduleLong.once.map((row) => row.count),
},
{
label: "Intervals",
data: data.scheduleLong.interval.map((row) => row.count),
},
],
},
@ -49,11 +63,15 @@ document.addEventListener("DOMContentLoaded", () => {
maintainAspectRatio: false,
scales: {
x: {
stacked: true,
type: "time",
time: {
unit: "day",
},
},
y: {
stacked: true,
},
},
},
});