Chart

React charts on Recharts with line, bar, area, pie, and radar views plus an interactive bar chart, themed through CSS variables with matching tooltips.

Loading preview

Examples

Practical examples and common states for the same installable component.

Bar

Compares values across different categories.

examples/chart-bar.tsx
import { ChartBar } from "@/components/wensity/chart";
const data = [
{ channel: "Jan", desktop: 186, mobile: 120 },
{ channel: "Feb", desktop: 205, mobile: 138 },
{ channel: "Mar", desktop: 174, mobile: 151 },
];
const config = {
desktop: { label: "Desktop" },
mobile: { label: "Mobile" },
};
export default function Example() {
return <ChartBar data={data} config={config} xKey="channel" />;
}

Area

Shows trends with emphasized data volume.

examples/chart-area.tsx
import { ChartArea } from "@/components/wensity/chart";
const data = [
{ month: "Jan", revenue: 4200, expenses: 2800 },
{ month: "Feb", revenue: 5100, expenses: 3100 },
];
const config = {
revenue: { label: "Revenue" },
expenses: { label: "Expenses" },
};
export default function Example() {
return <ChartArea data={data} config={config} xKey="month" stacked />;
}

Pie

Displays proportional parts of a whole.

examples/chart-pie.tsx
import { ChartPie } from "@/components/wensity/chart";
const data = [
{ name: "Chrome", value: 612 },
{ name: "Safari", value: 218 },
{ name: "Firefox", value: 96 },
{ name: "Edge", value: 74 },
];
const config = {
Chrome: { label: "Chrome" },
Safari: { label: "Safari" },
Firefox: { label: "Firefox" },
Edge: { label: "Edge" },
};
export default function Example() {
return <ChartPie data={data} config={config} height={260} />;
}

Radar

Compares multiple metrics across categories.

examples/chart-radar.tsx
import { ChartRadar } from "@/components/wensity/chart";
const data = [
{ metric: "Speed", team: 120, org: 98 },
{ metric: "Quality", team: 98, org: 90 },
{ metric: "Reliability", team: 110, org: 95 },
];
const config = {
team: { label: "This team" },
org: { label: "Org average" },
};
export default function Example() {
return <ChartRadar data={data} config={config} xKey="metric" height={280} />;
}

Bar (interactive)

Toggleable series with running totals, matching shadcn's interactive bar chart.

examples/chart-bar-interactive.tsx
import { ChartBarInteractive } from "@/components/wensity/chart";
const data = [
{ date: "2024-04-01", desktop: 222, mobile: 150 },
{ date: "2024-04-02", desktop: 97, mobile: 180 },
{ date: "2024-04-03", desktop: 167, mobile: 120 },
// ...30 days total (April 1 - April 30, 2024)
];
const config = {
desktop: { label: "Desktop", color: "#3987e5" },
mobile: { label: "Mobile", color: "#199e70" },
};
export default function Example() {
return (
<ChartBarInteractive
data={data}
config={config}
xKey="date"
title="Bar Chart - Interactive"
description="Showing total visitors for the last 3 months"
unitLabel="Page Views"
dateFormat
/>
);
}

Overview

Chart is a React and Tailwind CSS chart kit built on Recharts, in Next.js or any React app, with line, bar, area, pie, and radar charts plus an interactive bar chart that switches series with tabs. A config object names every series and can give it a color, which becomes a CSS variable so tooltips, legends, and bars stay matched, falling back to six theme chart colors. Charts fill their container, axes share one quiet style, and the entry animation is off under reduced motion. Series keys in config must match the keys in your data rows.

Installation

Run the following command

~/your-project
pnpm dlx wensity@latest add chart

Usage

Import Chart from @/components/wensity/chart and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.

app/example.tsx
import { ChartLine } from "@/components/wensity/chart";
const data = [
{ month: "Jan", revenue: 4200, expenses: 2800 },
{ month: "Feb", revenue: 5100, expenses: 3100 },
{ month: "Mar", revenue: 4800, expenses: 2950 },
];
const config = {
revenue: { label: "Revenue" },
expenses: { label: "Expenses" },
};
export default function Example() {
return <ChartLine data={data} config={config} xKey="month" />;
}

Props

PropTypeDefaultDescription
configChartConfig-Series keys mapped to labels and colours. Injected as --color-<key> variables. Required.
heightnumber280Chart height in pixels. The width is responsive.
childrenReact.ReactElement-The Recharts chart to wrap. Required.
  • KPI Card with Sparkline component preview

    KPI Card with Sparkline

    Dashboard KPI cards with a smooth SVG sparkline chart and a glowing dot that snaps to whichever value you scrub across.

  • GitHub-Style Activity Grid component preview

    GitHub-Style Activity Grid

    365 squares sharing one tooltip that flies between days on rails, with a reveal that ripples backward from today.

  • Bento Grid Layout component preview

    Bento Grid Layout

    A responsive bento grid of dashboard tiles where clicking one moves it to the front and the rest glide into place.

  • Interactive 3D Globe component preview

    Interactive 3D Globe

    A 3D Earth lit day and night from the real sun position, wrapped in a soft atmosphere, with smooth drag-to-orbit controls.