fix min date chart bug when using all time

This commit is contained in:
Francis Cao 2024-11-27 10:38:45 -08:00
parent bf89dfdd49
commit c851f3bb3c
4 changed files with 19 additions and 7 deletions

View file

@ -1,9 +1,9 @@
import { useMemo } from 'react';
import { colord } from 'colord';
import BarChart from 'components/charts/BarChart';
import { useLocale, useDateRange, useWebsiteEventsSeries } from 'components/hooks';
import { CHART_COLORS } from 'lib/constants';
import { useDateRange, useLocale, useWebsiteEventsSeries } from 'components/hooks';
import { renderDateLabels } from 'lib/charts';
import { CHART_COLORS } from 'lib/constants';
import { useMemo } from 'react';
export interface EventsChartProps {
websiteId: string;
@ -12,7 +12,7 @@ export interface EventsChartProps {
export function EventsChart({ websiteId, className }: EventsChartProps) {
const {
dateRange: { startDate, endDate, unit },
dateRange: { startDate, endDate, unit, value },
} = useDateRange(websiteId);
const { locale } = useLocale();
const { data, isLoading } = useWebsiteEventsSeries(websiteId);
@ -55,6 +55,7 @@ export function EventsChart({ websiteId, className }: EventsChartProps) {
stacked={true}
renderXLabel={renderDateLabels(unit, locale)}
isLoading={isLoading}
isAllTime={value === 'all'}
/>
);
}

View file

@ -14,9 +14,16 @@ export interface PagepageviewsChartProps extends BarChartProps {
};
unit: string;
isLoading?: boolean;
isAllTime?: boolean;
}
export function PagepageviewsChart({ data, unit, isLoading, ...props }: PagepageviewsChartProps) {
export function PagepageviewsChart({
data,
unit,
isLoading,
isAllTime,
...props
}: PagepageviewsChartProps) {
const { formatMessage, labels } = useMessages();
const { colors } = useTheme();
const { locale } = useLocale();
@ -74,6 +81,7 @@ export function PagepageviewsChart({ data, unit, isLoading, ...props }: Pagepage
data={chartData}
unit={unit}
isLoading={isLoading}
isAllTime={isAllTime}
renderXLabel={renderDateLabels(unit, locale)}
/>
);