Word-wrap overflown X-axis labels
See original GitHub issuehttps://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:
- Created 6 years ago
- Comments:10 (4 by maintainers)
Top 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 >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
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 thefont-size
for smaller screen widths, e.g.@media screen and (max-width: 480px){ .recharts-cartesian-axis-ticks { font-size: 10.5px; }
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/