Files
fitaiProto/apps/admin/src/components/charts/UserGrowthChart.tsx
T

60 lines
1.1 KiB
TypeScript

"use client";
import React, { useMemo } from "react";
import { AgCharts } from "ag-charts-react";
import { AgChartOptions } from "ag-charts-community";
interface ChartData {
label: string;
value: number;
color?: string;
}
interface UserGrowthChartProps {
data: ChartData[];
title?: string;
}
export function UserGrowthChart({
data,
title = "User Growth",
}: UserGrowthChartProps) {
const chartOptions: AgChartOptions = useMemo(
() =>
({
title: {
text: title,
},
data,
series: [
{
type: "line",
xKey: "label",
yKey: "value",
stroke: "#3b82f6",
strokeWidth: 3,
marker: {
size: 6,
fill: "#3b82f6",
stroke: "#ffffff",
strokeWidth: 2,
},
},
],
axes: [
{
type: "category",
position: "bottom",
},
{
type: "number",
position: "left",
},
],
}) as any,
[data, title],
);
return <AgCharts options={chartOptions} />;
}