File size: 1,161 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
"use client"
import { Chart, useChart } from "@chakra-ui/charts"
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts"
export const BarChartRounded = () => {
const chart = useChart({
data: [
{ allocation: 60, type: "Stock" },
{ allocation: 45, type: "Crypto" },
{ allocation: 12, type: "ETF" },
{ allocation: 4, type: "Cash" },
],
series: [{ name: "allocation", color: "teal.solid" }],
})
return (
<Chart.Root maxH="sm" chart={chart}>
<BarChart data={chart.data} barSize={40}>
<CartesianGrid stroke={chart.color("border.muted")} vertical={false} />
<XAxis axisLine={false} tickLine={false} dataKey={chart.key("type")} />
<YAxis
axisLine={false}
tickLine={false}
domain={[0, 100]}
tickFormatter={(value) => `${value}%`}
/>
{chart.series.map((item) => (
<Bar
key={item.name}
isAnimationActive={false}
dataKey={chart.key(item.name)}
fill={chart.color(item.color)}
radius={10}
/>
))}
</BarChart>
</Chart.Root>
)
}
|