Valid JSON with 6 records
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; const data = [ { "month": "Jan", "sales": 4000, "profit": 2400 }, { "month": "Feb", "sales": 3000, "profit": 1398 }, { "month": "Mar", "sales": 2000, "profit": 9800 }, { "month": "Apr", "sales": 2780, "profit": 3908 }, { "month": "May", "sales": 1890, "profit": 4800 }, { "month": "Jun", "sales": 2390, "profit": 3800 } ]; const colors = ["#8b5cf6","#06b6d4","#10b981","#f59e0b","#ef4444","#8b5cf6"]; export default function Chart() { return ( <ResponsiveContainer width="100%" height={400}> <BarChart data={data}> <CartesianGrid strokeDasharray="3 3" /> <XAxis dataKey="month" /> <YAxis /> <Tooltip /> <Legend /> <Bar dataKey="sales" fill={colors[0]} /> </BarChart> </ResponsiveContainer> ); }
What if validation fails?
Ensure valid JSON array input, then select correct X/Y keys with numeric Y values.
Can I export an image?
We export code. For images, consider html2canvas or server-side rendering workflows.
How do I customize colors?
Adjust the color array in the configuration panel; charts update instantly.