diff --git a/src/components/charts/Chart.tsx b/src/components/charts/Chart.tsx index abaa6eb8..ba49796e 100644 --- a/src/components/charts/Chart.tsx +++ b/src/components/charts/Chart.tsx @@ -111,7 +111,7 @@ export function Chart({ } else { const { index } = item; const meta = chart.current.getDatasetMeta(0); - const hidden = !!meta.data[index].hidden; + const hidden = !!meta?.data?.[index]?.hidden; meta.data[index].hidden = !hidden; chart.current.legend.legendItems[index].hidden = !hidden; diff --git a/src/lib/date.ts b/src/lib/date.ts index a7112029..19cd3d48 100644 --- a/src/lib/date.ts +++ b/src/lib/date.ts @@ -164,7 +164,7 @@ export function parseDateRange(value: string | object, locale = 'en-US'): DateRa case 'day': return { startDate: subDays(startOfDay(now), num), - endDate: endOfDay(now), + endDate: subDays(endOfDay(now), num ? 1 : 0), unit: num ? 'day' : 'hour', offset: 0, num: num || 1, @@ -181,8 +181,8 @@ export function parseDateRange(value: string | object, locale = 'en-US'): DateRa }; case 'month': return { - startDate: subMonths(startOfMonth(now), 1), - endDate: subMonths(endOfMonth(now), 1), + startDate: subMonths(startOfMonth(now), num), + endDate: subMonths(endOfMonth(now), num), unit: 'day', offset: 0, num: num || 1, @@ -190,8 +190,8 @@ export function parseDateRange(value: string | object, locale = 'en-US'): DateRa }; case 'year': return { - startDate: subYears(startOfYear(now), 1), - endDate: subYears(endOfYear(now), 1), + startDate: subYears(startOfYear(now), num), + endDate: subYears(endOfYear(now), num), unit: 'month', offset: 0, num: num || 1,