Installation
Install dune-charts and add styles to your app.
Install
npm install @suveshmoza/dune-charts rechartsPeer dependencies: react, react-dom, and recharts. Use React 18+ and Recharts 3.
Import
import {
DuneChartProvider,
DuneAreaChart,
DuneBarChart,
DuneLineChart,
DunePieChart,
DuneRadarChart,
DuneRadialChart,
} from '@suveshmoza/dune-charts';
import '@suveshmoza/dune-charts/styles.css';Import the stylesheet once at your app root. That loads theme tokens (--dune-*) and chart styles.
Minimal example
- Wrap the tree in
DuneChartProvider. - Pass
data(and optionalconfig) on the chart root. - Add the parts you need as children.
import { DuneChartProvider, DuneAreaChart } from '@suveshmoza/dune-charts';
import '@suveshmoza/dune-charts/styles.css';
const data = [
{ month: 'Jan', melange: 42, water: 28 },
{ month: 'Feb', melange: 48, water: 26 },
];
export function OpsChart() {
return (
<DuneChartProvider theme="dune">
<DuneAreaChart data={data} fill="dither" pixel={2}>
<DuneAreaChart.XAxis dataKey="month" />
<DuneAreaChart.YAxis />
<DuneAreaChart.Area dataKey="melange" />
<DuneAreaChart.Area dataKey="water" />
</DuneAreaChart>
</DuneChartProvider>
);
}Next.js
Charts use hooks and canvas, so they must run as Client Components. Import them in a file with 'use client', or wrap your demo behind a client boundary (same pattern as these docs).