nyuchimzizi
Mzizi — an open-architecture project of the Bundu Foundation, operated and developed by Nyuchi. Built on the Five African Minerals palette.
Built by Nyuchi Africav4.0.39
Line chart — label custom variant.
View the full component source code below.
"use client"
import { CartesianGrid, LabelList, Line, LineChart, XAxis } from "recharts"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import {
ChartConfig,
ChartContainer,
ChartTooltip,
ChartTooltipContent,
} from "@/components/ui/chart"
const DEFAULT_DATA = [
{ month: "Jan", temperature: 28, city: "Harare" },
{ month: "Feb", temperature: 30, city: "Harare" },
{ month: "Mar", temperature: 27, city: "Harare" },
{ month: "Apr", temperature: 24, city: "Harare" },
{ month: "May", temperature: 20, city: "Harare" },
{ month: "Jun", temperature: 18, city: "Harare" },
]
const config = {
temperature: { label: "Temperature", color: "var(--color-malachite, #64FFDA)" },
} satisfies ChartConfig
export function ChartLineLabelCustom({ loading = false }: { loading?: boolean } = {}) {
return (
<Card role="figure" data-slot="chart-block" data-portal="https://design.nyuchi.com/components/chart-block" aria-label="Line chart">
<CardHeader>
<CardTitle>Line Chart - Custom Labels</CardTitle>
<CardDescription>Labels with custom formatting</CardDescription>
</CardHeader>
<CardContent>
<ChartContainer config={config} loading={loading}>
<LineChart data={DEFAULT_DATA} margin={{ left: 12, right: 12, top: 24 }}>
<CartesianGrid vertical={false} />
<XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
<ChartTooltip content={<ChartTooltipContent />} />
<Line
type="natural"
dataKey="temperature"
stroke="var(--color-temperature)"
strokeWidth={2}
dot={{ fill: "var(--color-temperature)" }}
activeDot={{ r: 6 }}
>
<LabelList
position="top"
offset={12}
className="fill-foreground"
fontSize={11}
formatter={(value) => `${value}\u00B0C`}
/>
</Line>
</LineChart>
</ChartContainer>
</CardContent>
</Card>
)
}
npx shadcn@latest add https://mzizi.dev/api/v1/ui/chart-line-label-customFetch this component's metadata and source code from the registry API.
/api/v1/ui/chart-line-label-customcomponents/blocks/charts/chart-line-label-custom.tsx