Recharts: XAxis number cutoff on vertical bar chart

Created on 24 Oct 2016  路  3Comments  路  Source: recharts/recharts

The following chart:

<ResponsiveContainer width="100%" height="100%">
  <ComposedChart layout="vertical" data={data} >
    <XAxis type="number"/>
    <YAxis dataKey="name" type="category" width={200}/>
    <CartesianGrid stroke="#f5f5f5"/>
    <Tooltip/>
    <Legend />
    <Bar dataKey="OS" barSize={20} fill="#8884d8" />
  </ComposedChart>
</ResponsiveContainer>

is cutting off the number on the Xaxis like so:

image

The standard barchart with same dataset was not cutting off the labels on XAxis.

Enhancement

Most helpful comment

You can set the margin property of the ComposedChart like this: margin={{right: 10}}

All 3 comments

You can set the margin property of the ComposedChart like this: margin={{right: 10}}

@hi-bazinga The margin does the trick, however it would be preferable if something more dynamic could be added to handle this scenario.

Yeah this has been a pain point for me. When charting a customers spend, some will be spending $10 while others could be in the $100,000 range. This means i have a fairly large amount of wasted space on many charts to account for the larger spend customers.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

velociwabbit picture velociwabbit  路  3Comments

amitava82 picture amitava82  路  3Comments

sdoomz picture sdoomz  路  3Comments

emiloberg picture emiloberg  路  3Comments

FabioFleitas picture FabioFleitas  路  3Comments