Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Defining label position on x-axis
LabPusher
Hi,
in my chart, I want to define the interval of the labels shown on the x-axis.
I can do this by choosing interval = 3 very simple.
Now the 1. label, the 4. label are displayed and so on.
How can I change this to be shown the 3. , 6. ... ?
Since there is no option in the GUI, I think it has to be done by a script ?
Thx a lot
Axel
Find more posts tagged with
Comments
mwilliams
Hi Axel,<br />
<br />
Try this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
i=1;
function beforeDrawAxisLabel( axis, label, icsc )
{
if (axis.isCategoryAxis()){
if (i%3 == 0){
label.setVisible(true);
}
else{
label.setVisible(false);
}
i++;
}
}
</pre>
LabPusher
very nice !
Does this have effect on all charts of my report ?
Shouldn't I reduce the script on one special chart ? By any restrictions in the script ?
I just tried out, it changed the behaviour of reporting, but till now I didn't get the desired result.
Have a nice day !
mwilliams
This code should only change the chart that you put it in. Is this not what you're seeing?
LabPusher
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="77300" data-time="1305899385" data-date="20 May 2011 - 06:49 AM"><p>
This code should only change the chart that you put it in. Is this not what you're seeing?<br /></p></blockquote>
Hi,<br />
<br />
I put the script on the main level, belonging to the report.<br />
<br />
As I understand you, it has to be put directly to the chart.<br />
I expected the place to put the script in, should be :<br />
Format chart -> chart area -> X-axis<br />
<br />
but I couldn't find any position to integrate it properly :wacko: <br />
<br />
HAND
mwilliams
The script above should just go in the onRender script of the chart. Let me know if you have any questions!
LabPusher
hi,
I am using Birt Report Designer with Birt 2.3.1
And I don't see an "onRender"-option belonging to the chart.
I just can add a (onRender-)script to the whole report.
Does it depend on the (birt) version ?
HAND
mwilliams
In the designer, if you click on your chart and then select the script tab under the design window, you'll see the onRender method there.
LabPusher
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="77398" data-time="1306160422" data-date="23 May 2011 - 07:20 AM"><p>
In the designer, if you click on your chart and then select the script tab under the design window, you'll see the onRender method there.<br /></p></blockquote>
<br />
:blink: That's what I did without knowning.
<br />
Now I also know why the other chart was not effected by the script.<br />
<br />
there's one reason why I didn't see that at the first time:<br />
Since my labels are too long to be displayed one by one, the engine automatically removes every 2nd label. when I tell the engine to display every 3rd one (as in your script), the effect is , that 1 of 6 labels is displayed !!!<br />
<br />
I found out by taking short labels.<br />
<br />
My final solution is turn the labels for 90 degrees. That works fine !
<br />
<br />
Thx a lot
mwilliams
Glad you found the rotation setting! Let us know whenever you have questions!