mirror of
https://github.com/documenso/documenso.git
synced 2025-11-20 19:51:32 +10:00
chore: add tooltip
This commit is contained in:
@ -1,7 +1,9 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
import type { TooltipProps } from 'recharts';
|
||||||
import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
|
import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
|
||||||
|
import type { NameType, ValueType } from 'recharts/types/component/DefaultTooltipContent';
|
||||||
|
|
||||||
import type { GetMonthlyActiveUsersResult } from '@documenso/lib/server-only/admin/get-users-stats';
|
import type { GetMonthlyActiveUsersResult } from '@documenso/lib/server-only/admin/get-users-stats';
|
||||||
|
|
||||||
@ -12,6 +14,22 @@ export type MonthlyActiveUsersChartProps = {
|
|||||||
data: GetMonthlyActiveUsersResult;
|
data: GetMonthlyActiveUsersResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const CustomTooltip = ({ active, payload, label }: TooltipProps<ValueType, NameType>) => {
|
||||||
|
if (active && payload && payload.length) {
|
||||||
|
return (
|
||||||
|
<div className="z-100 w-60 space-y-1 rounded-md border border-solid bg-white p-2 px-3">
|
||||||
|
<p>{label}</p>
|
||||||
|
<p className="text-documenso">
|
||||||
|
{payload[0].name === 'cume_count' ? 'Cumulative MAU' : 'Monthly Active Users'}:{' '}
|
||||||
|
<span className="text-black">{Number(payload[0].value).toLocaleString('en-US')}</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
export const MonthlyActiveUsersChart = ({
|
export const MonthlyActiveUsersChart = ({
|
||||||
className,
|
className,
|
||||||
data,
|
data,
|
||||||
@ -38,16 +56,7 @@ export const MonthlyActiveUsersChart = ({
|
|||||||
<XAxis dataKey="month" />
|
<XAxis dataKey="month" />
|
||||||
<YAxis />
|
<YAxis />
|
||||||
|
|
||||||
<Tooltip
|
<Tooltip content={<CustomTooltip />} cursor={{ fill: 'hsl(var(--primary) / 10%)' }} />
|
||||||
labelStyle={{
|
|
||||||
color: 'hsl(var(--primary-foreground))',
|
|
||||||
}}
|
|
||||||
formatter={(value) => [
|
|
||||||
Number(value).toLocaleString('en-US'),
|
|
||||||
cummulative ? 'Cumulative MAU' : 'Monthly Active Users',
|
|
||||||
]}
|
|
||||||
cursor={{ fill: 'hsl(var(--primary) / 10%)' }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Bar
|
<Bar
|
||||||
dataKey={cummulative ? 'cume_count' : 'count'}
|
dataKey={cummulative ? 'cume_count' : 'count'}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
|
|
||||||
import type { TooltipProps } from 'recharts';
|
import type { TooltipProps } from 'recharts';
|
||||||
|
import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
|
||||||
import type { NameType, ValueType } from 'recharts/types/component/DefaultTooltipContent';
|
import type { NameType, ValueType } from 'recharts/types/component/DefaultTooltipContent';
|
||||||
|
|
||||||
import type { GetUserWithDocumentMonthlyGrowth } from '@documenso/lib/server-only/admin/get-users-stats';
|
import type { GetUserWithDocumentMonthlyGrowth } from '@documenso/lib/server-only/admin/get-users-stats';
|
||||||
|
|||||||
Reference in New Issue
Block a user