Treemap label wrapping not working
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:
Current behavior
When the treemap label is longer than it’s rect, it doesn’t wrap and instead just disappears.
Expected behavior
Labels wrap nicely.
Minimal reproduction of the problem with instructions
I’ve checked the current shape of the wrapText
function here and while looping over the words, in lines 33 and 38 it always adds the word width to the sum. It then compares sumWidth
to container width in line 52 and if we need wrapping, it’s obviously longer, so it returns null
.
Since wrapText
is used in different charts as well and I’ve just started using reaviz, I’m probably not the person to fix it so I don’t cause any regressions.
const simpleData: ChartShallowDataShape[] = [
{
key: "Very long text, make it as long as necessary or shrink the treemap width so it's longer than the rect's width.",
data: 1,
},
]
return <TreeMap
height={400}
data={simpleData}
margins={20}
series={
<TreeMapSeries />
}
/>
Environment
Libs:
"react": "17.0.2",
"reaviz": "13.1.3"
Others:
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Text wrap for TreeMap label · Issue #377 · plouc/nivo - GitHub
It seems like TreeMap's label property can only render strings as opposed to html entities, and adding "\n" to the strings doesn't break ......
Read more >Treemap: data label wrapping - Highcharts official support forum
1.3 - the label no longer wraps by default due to the css styling on the span that highcharts places around the customised...
Read more >How can I get treemap datalabels to wrap consistently?
Sometimes they wrap, sometimes highcharts truncates them with ellipses (but it really seems like it could wrap them instead).
Read more >word wrap on treemap visual - Microsoft Power BI Community
Solved! Go to Solution. Labels: Labels: General Comment.
Read more >Label hiding instead of label wrapping - Tableau Community
I've got a couple of treemaps, where both wrapped and unwrapped label setting seems to be causing problems. Below in the image see...
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
@puripant - We would welcome any contributions!
Hi, I am new to this repo but would like to contribute, especially to this issue. I looked into
wrapText.tsx
and found a few things that made it not working for treemap. For example, the sum of word widths (plus spaces) was not the same as runningcalculateDimensions()
on the whole sentence, probably due to kerning and such.paddingX
had no default value and could beundefined
and etc. I editedwrapText()
as follows.I also wrote a treemap example with long text labels in the Storybook to test it.
wrapText()
was used in two other charts: bubble chart and Venn diagram. I checked their examples with long label texts and they worked fine as well.If this sounds okay, I can create a pull request.