mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-01 12:29:35 +01:00
Fixed chart.
This commit is contained in:
parent
b1024c71de
commit
3217ef3df3
@ -3,20 +3,20 @@ import BarChart, { BarChartProps } from 'components/charts/BarChart';
|
|||||||
import { useLocale, useTheme, useMessages } from 'components/hooks';
|
import { useLocale, useTheme, useMessages } from 'components/hooks';
|
||||||
import { renderDateLabels } from 'lib/charts';
|
import { renderDateLabels } from 'lib/charts';
|
||||||
|
|
||||||
export interface PageviewsChartProps extends BarChartProps {
|
export interface PagepageviewsChartProps extends BarChartProps {
|
||||||
data: {
|
data: {
|
||||||
views: any[];
|
pageviews: any[];
|
||||||
visitors: any[];
|
sessions: any[];
|
||||||
compare?: {
|
compare?: {
|
||||||
views: any[];
|
pageviews: any[];
|
||||||
visitors: any[];
|
sessions: any[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
unit: string;
|
unit: string;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PageviewsChart({ data, unit, isLoading, ...props }: PageviewsChartProps) {
|
export function PagepageviewsChart({ data, unit, isLoading, ...props }: PagepageviewsChartProps) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { locale } = useLocale();
|
const { locale } = useLocale();
|
||||||
@ -29,15 +29,15 @@ export function PageviewsChart({ data, unit, isLoading, ...props }: PageviewsCha
|
|||||||
return {
|
return {
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: formatMessage(labels.visitors),
|
label: formatMessage(labels.sessions),
|
||||||
data: data.visitors,
|
data: data.sessions,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
...colors.chart.visitors,
|
...colors.chart.visitors,
|
||||||
order: 3,
|
order: 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: formatMessage(labels.views),
|
label: formatMessage(labels.pageviews),
|
||||||
data: data.views,
|
data: data.pageviews,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
...colors.chart.views,
|
...colors.chart.views,
|
||||||
order: 4,
|
order: 4,
|
||||||
@ -46,8 +46,8 @@ export function PageviewsChart({ data, unit, isLoading, ...props }: PageviewsCha
|
|||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
type: 'line',
|
type: 'line',
|
||||||
label: `${formatMessage(labels.views)} (${formatMessage(labels.previous)})`,
|
label: `${formatMessage(labels.pageviews)} (${formatMessage(labels.previous)})`,
|
||||||
data: data.compare.views,
|
data: data.compare.pageviews,
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
backgroundColor: '#8601B0',
|
backgroundColor: '#8601B0',
|
||||||
borderColor: '#8601B0',
|
borderColor: '#8601B0',
|
||||||
@ -55,8 +55,8 @@ export function PageviewsChart({ data, unit, isLoading, ...props }: PageviewsCha
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'line',
|
type: 'line',
|
||||||
label: `${formatMessage(labels.visitors)} (${formatMessage(labels.previous)})`,
|
label: `${formatMessage(labels.sessions)} (${formatMessage(labels.previous)})`,
|
||||||
data: data.compare.visitors,
|
data: data.compare.sessions,
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
backgroundColor: '#f15bb5',
|
backgroundColor: '#f15bb5',
|
||||||
borderColor: '#f15bb5',
|
borderColor: '#f15bb5',
|
||||||
@ -79,4 +79,4 @@ export function PageviewsChart({ data, unit, isLoading, ...props }: PageviewsCha
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PageviewsChart;
|
export default PagepageviewsChart;
|
||||||
|
@ -18,12 +18,12 @@ export function RealtimeChart({ data, unit, ...props }: RealtimeChartProps) {
|
|||||||
|
|
||||||
const chartData = useMemo(() => {
|
const chartData = useMemo(() => {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return { views: [], visitors: [] };
|
return { pageviews: [], sessions: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
views: getDateArray(data.series.views, startDate, endDate, unit),
|
pageviews: getDateArray(data.series.views, startDate, endDate, unit),
|
||||||
visitors: getDateArray(data.series.visitors, startDate, endDate, unit),
|
sessions: getDateArray(data.series.visitors, startDate, endDate, unit),
|
||||||
};
|
};
|
||||||
}, [data, startDate, endDate, unit]);
|
}, [data, startDate, endDate, unit]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user