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.

Word-wrap overflown X-axis labels

See original GitHub issue

https://github.com/recharts/recharts/issues/198

This is supposedly fixed by https://github.com/recharts/recharts/pull/243 but it doesn’t seem to work.

How do I use it? <XAxis dataKey="name" interval={0} width={30} label={<Text width={30} />} />? @techniq

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

20reactions
lisamartin00commented, Oct 17, 2018

I was finally able to figure it out based on their Line Chart Example fiddle, which uses a custom component passed into the <XAxis> tick property. https://jsfiddle.net/alidingling/5br7g9d6/

You can do something similar to what they’ve done and return the <Text> element https://jsfiddle.net/lisamartin00/exasjofp/ Now you can set a fixed width and the text will wrap. You may still need to write some custom media queries to adjust the font-size for smaller screen widths, e.g. @media screen and (max-width: 480px){ .recharts-cartesian-axis-ticks { font-size: 10.5px; }

7reactions
deadlyfingerscommented, Dec 13, 2018

If you need word wrap on long string or word which has no spaces I have a fiddle which shows how to chunk long text strings and splits it up into multiple tspan elements. https://jsfiddle.net/deadlyfingers/jngsxqyo/85/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrap long axis labels via labeller=label_wrap in ggplot2
This solution appears to be very close to my problem. But what if every three graph has different labels? Do I have to...
Read more >
overflow-wrap - CSS: Cascading Style Sheets - MDN Web Docs
The overflow-wrap CSS property applies to inline elements, setting whether the browser should insert line breaks within an otherwise ...
Read more >
Learn Excel - Chart X-Axis Labels Word Wrap - Podcast 1797
jiayouluckystar from YouTube asks about controlling the word wrap of long labels along the x - axis. While the chart format dialog offers...
Read more >
xAxis.labels.overflow | highstock API Reference - Highcharts API
Set it to undefined to disable rotation, which will cause the labels to word-wrap if possible. Defaults to [-45]`` on bottom and top...
Read more >
Automatically Wrap Graph Labels in Matplotlib and Seaborn
... and seaborn to create data visualizations enough, then you've probably run into the issue of overlapping text labels on the x-axis.
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