Appearance
Chart
Bề mặt thống kê Soft Periwinkle light cho Dashboard / Stats. Dựa trên shadcn Chart; peer Recharts optional (xem Install → Chart).
ts
import {
ChartContainer,
ChartLegend,
ChartLegendContent,
ChartTooltip,
ChartTooltipContent,
type ChartConfig,
} from "@minap/ui";
import { Bar, BarChart, CartesianGrid, XAxis } from "recharts";Peer install
recharts không hard-depend mọi consumer. Application dùng Chart MUST cài:
bash
pnpm add recharts@^2.15.0Kit-tested: recharts@2.15.4 (playground). Chi tiết: Install → Chart.
Public API = Chart* trên @minap/ui — không re-export Recharts primitives làm primary API.
Soft Periwinkle light
- Token series:
--chart-1…--chart-5(light only). - Không dark mode chart theme trong kit hiện tại.
- Mobile-First: container
w-full/ ~375px; legend/tooltip không phải đường đọc số liệu duy nhất — kèm KPI / summary text khi meaningful.
Examples
Mẫu sống trong Preview; chọn View code khi cần copy. Cần peer recharts (xem Install).
Ready
tsx
import {
ChartContainer,
ChartLegend,
ChartLegendContent,
ChartTooltip,
ChartTooltipContent,
type ChartConfig,
} from "@minap/ui";
import { Bar, BarChart, CartesianGrid, XAxis } from "recharts";
const config = {
visits: { label: "Visits", color: "var(--chart-1)" },
} satisfies ChartConfig;
const data = [
{ day: "Mon", visits: 120 },
{ day: "Tue", visits: 98 },
{ day: "Wed", visits: 160 },
{ day: "Thu", visits: 140 },
{ day: "Fri", visits: 180 },
];
export function Example() {
return (
<ChartContainer config={config} className="min-h-[200px] w-full max-w-[375px]">
<BarChart accessibilityLayer data={data}>
<CartesianGrid vertical={false} />
<XAxis dataKey="day" tickLine={false} axisLine={false} />
<Bar dataKey="visits" fill="var(--color-visits)" radius={4} />
<ChartTooltip content={<ChartTooltipContent />} />
<ChartLegend content={<ChartLegendContent />} />
</BarChart>
</ChartContainer>
);
}States (empty / loading)
Empty và loading dùng composition đã publish — không phụ thuộc hover.
Loading
Dùng Skeleton (hoặc Spinner) trong khung cùng kích thước:
tsx
<div data-state="loading" className="min-h-[200px] w-full max-w-[375px]">
<Skeleton className="h-[200px] w-full" role="status" aria-label="Loading chart" />
</div>Empty
Dùng published Empty composition:
tsx
<div data-state="empty" className="flex min-h-[200px] w-full max-w-[375px] items-center justify-center">
<Empty>
<EmptyHeader>
<EmptyTitle>No chart data</EmptyTitle>
<EmptyDescription>Thêm series để xem Soft Periwinkle Chart.</EmptyDescription>
</EmptyHeader>
</Empty>
</div>Exports
| Export | Role |
|---|---|
ChartContainer | Context + ResponsiveContainer + Soft Periwinkle chart slot |
ChartStyle | Inject --color-* từ ChartConfig |
ChartTooltip / ChartTooltipContent | Tooltip Recharts + content styled |
ChartLegend / ChartLegendContent | Legend Recharts + content styled |
ChartConfig | Type config label/color/theme (light) |