Some XAxis not showing
See original GitHub issueI have a simple BarChart, with a XAxis. In some cases, some of the labels are simply not showing up. In the image below, only the middle label is appearing.
Here’s the code:
<BarChart data={data} barSize={SIZE} width={WIDTH} height={HEIGHT} margin={{ top: 80 }}>
<XAxis dataKey="name" tick={<CustomizedAxisTick />} />
<Tooltip formatter={formatTooltip} />
<Bar dataKey="local" fill="#1f40e6" label={<CustomizedLabel />} />
<Bar dataKey="global" fill="rgba(30, 63, 230, 0.6)" label={<CustomizedLabel />} />
</BarChart>
and
const CustomizedLabel = props => {
// eslint-disable-next-line react/prop-types
const { x, y, payload } = props;
return (
<Text
x={x}
y={y + 3}
fill="#002960"
fontSize={11}
textAnchor="middle"
>{truncate(payload.value)}</Text>
);
};
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:5 (1 by maintainers)
Top Results From Across the Web
X axis label is not displayed fully in recharts - Stack Overflow
I came across the same problem and fixed it by adding a margin to the chart, eg; <LineChart <LineChart margin={{ top: 0, right:...
Read more >Excel Chart not showing SOME X-axis labels - Super User
On the sidebar, click on "CHART OPTIONS" and select "Horizontal (Category) Axis" from the drop down menu. Four icons will appear below the...
Read more >Percentage symbol in x-axis not showing - WordPress.org
I am creating a Bar chart with percentage values (12%, 25%, etc.) in the table. However, x-axis does not show percentage symbol (“%”)...
Read more >Unable to edit X Axis and want to show all the labels on the axis
I am trying to edit the axis but for some reason, Edit axis option is not there also I don't want to change...
Read more >Customize X-axis and Y-axis properties - Power BI
The X-axis labels display below the columns in the chart. ... Some reasons you may want to set the X axis to Off,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@matheusml By default, we’ll hide some ticks of
XAxis
when no enough space.related code
If you want to show all the ticks, you can set the props
interval
ofXAxis
to be0
.I was also facing the same issue. Following is the snippet which worked for me:
<XAxis dataKey="name" textAnchor= "end" sclaeToFit="true" verticalAnchor= "start" interval={0} angle= "-40" stroke="#8884d8" />