Skip to content

Instantly share code, notes, and snippets.

@ericksoa
Created March 21, 2023 19:12
Show Gist options
  • Select an option

  • Save ericksoa/92c18550c88a0d074e0702b3c54557ce to your computer and use it in GitHub Desktop.

Select an option

Save ericksoa/92c18550c88a0d074e0702b3c54557ce to your computer and use it in GitHub Desktop.
Up and to the right, hurray!
// src/components/GrowthChart.tsx
import React from 'react';
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
interface GrowthData {
month: string;
revenue: number;
}
interface GrowthChartProps {
data: GrowthData[];
}
const GrowthChart: React.FC<GrowthChartProps> = ({ data }) => {
return (
<ResponsiveContainer width="100%" height={400}>
<LineChart
data={data}
margin={{ top: 20, right: 30, left: 20, bottom: 10 }}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="month" />
<YAxis />
<Tooltip />
<Legend />
<Line
type="monotone"
dataKey="revenue"
stroke="#8884d8"
activeDot={{ r: 8 }}
/>
</LineChart>
</ResponsiveContainer>
);
};
export default GrowthChart;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment