mango-v4-ui/components/shared/SimpleAreaChart.tsx

42 lines
931 B
TypeScript
Raw Normal View History

2022-08-02 17:17:42 -07:00
import { Area, AreaChart, XAxis, YAxis } from 'recharts'
const SimpleAreaChart = ({
color,
data,
height,
name,
width,
2022-08-10 21:09:58 -07:00
xKey,
yKey,
2022-08-02 17:17:42 -07:00
}: {
color: string
data: any[]
height: number
name: string
width: number
2022-08-10 21:09:58 -07:00
xKey: string
yKey: string
2022-08-02 17:17:42 -07:00
}) => {
return (
<AreaChart width={width} height={height} data={data}>
<defs>
<linearGradient id={`gradientArea-${name}`} x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor={color} stopOpacity={0.6} />
<stop offset="100%" stopColor={color} stopOpacity={0} />
</linearGradient>
</defs>
<Area
isAnimationActive={false}
type="monotone"
2022-08-10 21:09:58 -07:00
dataKey={yKey}
2022-08-02 17:17:42 -07:00
stroke={color}
fill={`url(#gradientArea-${name})`}
/>
2022-08-10 21:09:58 -07:00
<XAxis dataKey={xKey} hide />
<YAxis domain={['dataMin', 'dataMax']} dataKey={yKey} hide />
2022-08-02 17:17:42 -07:00
</AreaChart>
)
}
export default SimpleAreaChart