fix(dashboard): add weekly interval #154
This commit is contained in:
@@ -37,6 +37,10 @@ export function OverviewInterval() {
|
||||
value: 'day',
|
||||
label: 'Day',
|
||||
},
|
||||
{
|
||||
value: 'week',
|
||||
label: 'Week',
|
||||
},
|
||||
{
|
||||
value: 'month',
|
||||
label: 'Month',
|
||||
|
||||
@@ -62,6 +62,15 @@ export function ReportInterval({
|
||||
value: 'day',
|
||||
label: 'Day',
|
||||
},
|
||||
{
|
||||
value: 'week',
|
||||
label: 'Week',
|
||||
disabled:
|
||||
range === 'today' ||
|
||||
range === 'lastHour' ||
|
||||
range === '30min' ||
|
||||
range === '7d',
|
||||
},
|
||||
{
|
||||
value: 'month',
|
||||
label: 'Month',
|
||||
|
||||
@@ -13,6 +13,14 @@ export function formatDateInterval(interval: IInterval, date: Date): string {
|
||||
return new Intl.DateTimeFormat('en-GB', { month: 'short' }).format(date);
|
||||
}
|
||||
|
||||
if (interval === 'week') {
|
||||
return new Intl.DateTimeFormat('en-GB', {
|
||||
weekday: 'short',
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
if (interval === 'day') {
|
||||
return new Intl.DateTimeFormat('en-GB', {
|
||||
weekday: 'short',
|
||||
|
||||
@@ -3,12 +3,14 @@ import {
|
||||
addHours,
|
||||
addMinutes,
|
||||
addMonths,
|
||||
addWeeks,
|
||||
format,
|
||||
parseISO,
|
||||
startOfDay,
|
||||
startOfHour,
|
||||
startOfMinute,
|
||||
startOfMonth,
|
||||
startOfWeek,
|
||||
} from 'date-fns';
|
||||
|
||||
import { NOT_SET_VALUE } from '@openpanel/constants';
|
||||
@@ -39,6 +41,8 @@ function roundDate(date: Date, interval: IInterval): Date {
|
||||
return startOfHour(date);
|
||||
case 'day':
|
||||
return startOfDay(date);
|
||||
case 'week':
|
||||
return startOfWeek(date);
|
||||
case 'month':
|
||||
return startOfMonth(date);
|
||||
default:
|
||||
@@ -125,6 +129,9 @@ export function completeSerie(
|
||||
case 'day':
|
||||
currentDate = addDays(currentDate, 1);
|
||||
break;
|
||||
case 'week':
|
||||
currentDate = addWeeks(currentDate, 1);
|
||||
break;
|
||||
case 'month':
|
||||
currentDate = addMonths(currentDate, 1);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user