mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 17:15:37 +01:00
fix chart and timezone issues, pass consistent dates to DB.
Closes #3700
This commit is contained in:
parent
81bedec6d5
commit
6751bf88bb
10 changed files with 157 additions and 79 deletions
|
|
@ -3,6 +3,7 @@ import { startOfMinute, subMinutes, isBefore } from 'date-fns';
|
|||
import { PageviewsChart } from './PageviewsChart';
|
||||
import { DEFAULT_ANIMATION_DURATION, REALTIME_RANGE } from '@/lib/constants';
|
||||
import { RealtimeData } from '@/lib/types';
|
||||
import { useTimezone } from '@/components/hooks';
|
||||
|
||||
export interface RealtimeChartProps {
|
||||
data: RealtimeData;
|
||||
|
|
@ -11,6 +12,7 @@ export interface RealtimeChartProps {
|
|||
}
|
||||
|
||||
export function RealtimeChart({ data, unit, ...props }: RealtimeChartProps) {
|
||||
const { formatSeriesTimezone, fromUtc, timezone } = useTimezone();
|
||||
const endDate = startOfMinute(new Date());
|
||||
const startDate = subMinutes(endDate, REALTIME_RANGE);
|
||||
const prevEndDate = useRef(endDate);
|
||||
|
|
@ -21,8 +23,8 @@ export function RealtimeChart({ data, unit, ...props }: RealtimeChartProps) {
|
|||
}
|
||||
|
||||
return {
|
||||
pageviews: data.series.views,
|
||||
sessions: data.series.visitors,
|
||||
pageviews: formatSeriesTimezone(data.series.views, 'x', timezone),
|
||||
sessions: formatSeriesTimezone(data.series.visitors, 'x', timezone),
|
||||
};
|
||||
}, [data, startDate, endDate, unit]);
|
||||
|
||||
|
|
@ -38,8 +40,8 @@ export function RealtimeChart({ data, unit, ...props }: RealtimeChartProps) {
|
|||
return (
|
||||
<PageviewsChart
|
||||
{...props}
|
||||
minDate={startDate}
|
||||
maxDate={endDate}
|
||||
minDate={fromUtc(startDate)}
|
||||
maxDate={fromUtc(endDate)}
|
||||
unit={unit}
|
||||
data={chartData}
|
||||
animationDuration={animationDuration}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue