Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Setting wrapping in primary base axis
xehpuk
Hi,
I could not find a way to enable wrapping on the labels of the primary base axis.
When the caption text of a label is long, it overlaps the neighboring labels, causing them to hide their texts. Instead of that, I want it to wrap if it is too wide to fit in its own space. How to do this?
Find more posts tagged with
Comments
pricher
Hi Xehpuk,
As far as I know, you cannot make the labels wrap on a chart axis. My only recommendation is to rotate the labels 90 degrees.
P.
mwilliams
Hi Xehpuk,<br />
<br />
You certainly can force line breaks in your x-axis labels. You just have to do it in the chart script with something like the following:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawAxisLabel( axis, label, icsc )
{
var tst=label.getCaption().getValue();
if( tst.length() > 4 ){
label.getCaption().setValue(tst.substring(0,3)+"\r\n"+ tst.substring(4,tst.length()));
}
label.setVisible(true);
label.getCaption().getFont().setSize(7);
}
</pre>
<br />
I can post an example if needed. Let me know.
paqman
Hey Guys,<br />
<br />
I've been working on accomplishing something similar and have run into a slight problem. The wrapping is working fine with the following code (based off of the sample in this thread):<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawAxisLabel( axis, label, icsc )
{
var tst = label.getCaption().getValue();
var wrap = 20;
var repeat = Math.floor(tst.length() / wrap);
var str = tst;
if(repeat > 0)
{
str = "";
for(i = 0; i < repeat; i++)
{
str += tst.substring((i*wrap),((i+1)*wrap-1))+"\r\n";
}
if((tst.length() % wrap) > 0)
{
str += tst.substring((i*wrap-1),tst.length());
}
}
label.getCaption().setValue(str);
}</pre>
<br />
It wraps the text fine, but the chart still gets pushed up (looks like it calculates the space for x-axis labels before this, not knowing they will wrap):<br />
mwilliams
David,
Have you tried going to the "Labels" button on the x-axis section of the chart editor and playing with the "insets"?
XFabien
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="78863" data-time="1308689507" data-date="21 June 2011 - 01:51 PM"><p>
David,<br />
<br />
Have you tried going to the "Labels" button on the x-axis section of the chart editor and playing with the "insets"?<br /></p></blockquote>
<br />
Hello Michael,<br />
<br />
I have tried to play with the 'inserts' that you said above, but I can always not cancel the margin below the X-axis. Can you add un exemple with the right result?<br />
<br />
Thank you very much.<br />
<br />
<br />
Yao
mwilliams
Oh, I see. It's still set for the length of the actual long text. I would guess there's some way to change a setting in the chart wizard to fix this. What is your BIRT version so that I look at the correct version?
XFabien
My birt version is 2.6.2, thanks
mwilliams
You can play with the bottom inset, making it a negative number, but at a certain size, it removes some labels, presumably because it thinks it has a spacing issue. I think what really needs to be done for this is an enhancement request to allow for long labels to wrap. I'll keep working on this and let you know if I figure out a way to keep all labels visible.
Yaytay
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="84428" data-time="1319209563" data-date="21 October 2011 - 08:06 AM"><p>
You can play with the bottom inset, making it a negative number, but at a certain size, it removes some labels, presumably because it thinks it has a spacing issue. I think what really needs to be done for this is an enhancement request to allow for long labels to wrap. I'll keep working on this and let you know if I figure out a way to keep all labels visible.<br /></p></blockquote>
Hi Michael,<br />
<br />
Did you ever find a solution to this?<br />
<br />
We could really do with a built n way to wrap labels, but without that some way to overrule (or recalculate) the decision to hide labels is needed.<br />
<br />
Jim
mwilliams
Setting a negative inset on the plot, instead of on the label, works to keep showing all of the labels. Obviously this still isn't an ideal solution. Would you mind checking the bugs and seeing if this has been requested as an enhancement? If not, can you request it?