55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
"use client"
|
|
import type { CSSProperties } from "react";
|
|
import {
|
|
Card,
|
|
CardContent
|
|
} from "./lib/card";
|
|
import {
|
|
ChartContainer,
|
|
ChartTooltip,
|
|
ChartTooltipContent,
|
|
type ChartConfig
|
|
} from "./lib/chart";
|
|
import { CartesianGrid, Line, LineChart, XAxis } from "recharts";
|
|
|
|
export default function Linechart(props: { chartConfig: ChartConfig; chartData: any[] | undefined; chartTitle:string}) {
|
|
return (
|
|
<Card>
|
|
{props.chartTitle && props.chartTitle !== "" && props.chartTitle !== "undefined" ? (
|
|
<div style={{ textAlign: "left", fontSize: "13px", fontWeight: "bold", marginTop:"13px", marginBottom: "10px" }}>
|
|
{props.chartTitle}
|
|
</div>): null}
|
|
<CardContent>
|
|
<ChartContainer config={props.chartConfig}>
|
|
<LineChart
|
|
accessibilityLayer
|
|
data={props.chartData}
|
|
margin={{
|
|
left: 12,
|
|
right: 12,
|
|
}}
|
|
>
|
|
<CartesianGrid vertical={false} />
|
|
<XAxis
|
|
dataKey="month"
|
|
tickLine={false}
|
|
axisLine={false}
|
|
tickMargin={8}
|
|
tickFormatter={(value) => value.slice(0, 3)}
|
|
/>
|
|
<ChartTooltip
|
|
cursor={false}
|
|
content={<ChartTooltipContent hideLabel />}
|
|
/>
|
|
<Line
|
|
dataKey="val"
|
|
type="linear"
|
|
strokeWidth={2}
|
|
dot={false}
|
|
/>
|
|
</LineChart>
|
|
</ChartContainer>
|
|
</CardContent>
|
|
</Card>
|
|
)
|
|
} |