Can't make BarChart
expanding to full width
#3696
-
I have a strange issue that I am trying to wrap my head around. Basically, I am trying to create a staked const data = [
{
btc: 4000,
eth: 2400,
ada: 1600,
matic: 500,
},
]; The thing is that, even though I use Below there's my code and I leave also the CodeSandbox I was experimenting with. const HodlBar = ({ hodls }: { hodls: PositionsProps }) => {
const data = massageData(hodls);
const tokens = hodls.map((hodl) => hodl.token.symbol).slice(0, 5);
return (
<div className="h-12 w-full">
<ResponsiveContainer width="100%">
<BarChart className="mx-auto" layout="vertical" data={data}>
<XAxis type="number" hide={true} />
<YAxis type="category" dataKey="name" hide={true} />
<Tooltip shared={false} content={<CustomTooltip tokens={hodls} />} />
{tokens.map((token, index) => (
<Bar
key={token}
dataKey={token}
fill={barColors[index]}
stackId="holding"
className="cursor-pointer"
/>
))}
</BarChart>
</ResponsiveContainer>
</div>
);
}; Thanks to anyone will be able to help me out. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Is this what you are looking for? https://codesandbox.io/p/sandbox/rechart-experiments-c5qrs2 Its because the default domain isn't the min and the max of your data so setting domain={['dataMin', 'dataMax']} will do it |
Beta Was this translation helpful? Give feedback.
Is this what you are looking for? https://codesandbox.io/p/sandbox/rechart-experiments-c5qrs2
Its because the default domain isn't the min and the max of your data so setting domain={['dataMin', 'dataMax']} will do it