question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some XAxis not showing

See original GitHub issue

I 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.

http://i.imgur.com/MRFaXJP.png

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:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

99reactions
xile611commented, Dec 15, 2016

@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 of XAxis to be 0.

7reactions
roushanrajcommented, Sep 1, 2021

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" />

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found