Charts
Line chart
This week against last week (dashed) and a target line. One y-axis.
Revenue per day
৳ thousands
- This week
- Last week
line-chart.tsx
"use client";
import { ChartCard, LineChart, SERIES } from "@waveinno/ui";
const REVENUE = ["Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"].map((day, i) => ({
day,
now: [38, 44, 51, 47, 55, 58, 49][i]!,
last: [35, 39, 46, 45, 48, 50, 47][i]!,
}));
const LINE = [
{ id: "now", key: "now", label: "This week", color: SERIES[0] },
{ id: "last", key: "last", label: "Last week", color: SERIES[2], dashed: true },
];
export default function LineChartExample() {
return (
<ChartCard title="Revenue per day" description="৳ thousands" series={LINE}>
<LineChart data={REVENUE} xKey="day" series={LINE} target={{ value: 52, label: "Target 52k" }} format={(v) => `${v}k`} />
</ChartCard>
);
}Import#
Everything comes from the package root. The example above uses:
your-component.tsx
import { ChartCard, LineChart, SERIES } from "@waveinno/ui";Props#
Read from the source of this version, so they match the code exactly.
<LineChart>
src/components/charts/line-chart.tsx| Prop | Type | Default | Description |
|---|---|---|---|
datarequired | Record<string, string | number>[] | — | |
xKeyrequired | string | — | |
seriesrequired | LineSeries[] | — | |
format | (v: number) => string | (v) => String(v) | |
target | { value: number; label: string } | — | |
curved | boolean | true |
<ChartCard>
src/components/charts/chart-card.tsx| Prop | Type | Default | Description |
|---|---|---|---|
titlerequired | string | — | |
description | string | — | |
series | SeriesMeta[] | — | |
action | React.ReactNode | — | |
childrenrequired | React.ReactNode | — | |
className | string | — | |
height | number | 240 |
Install#
If the project does not have the package yet, add it, then follow the setup for Next.js or Vite once.
$ npm install @waveinno/ui