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)
How to dynamically change the legend in a chart?
sgruendel
Hi,
I have a chart with two Y axes and an Y series grouping. Now I get two sets of legends with the same colours, one for each Y axis I suppose. How can I change it so there is only one set of legends.
Or can I use some some JavaScipt code to dynamically change the elements in the legend at runtime?
Many thanks in advance, Stefan
Find more posts tagged with
Comments
Virgil Dodson
Hi Stefan,<br />
<br />
You can try writing some script into the beforeDrawLegendItem method.<br />
<br />
Read more here: <br />
<a class='bbc_url' href='
http://www.birt-exchange.com/documentation/BIRT_220/ChartJavadoc/chart/api/org/eclipse/birt/chart/script/IChartEventHandler.html'>http://www.birt-exchange.com/documentation/BIRT_220/ChartJavadoc/chart/api/org/eclipse/birt/chart/script/IChartEventHandler.html</a><br
/>
<br />
I'm not sure if this will do what you want. I personally have used it to change legend colors only like below... so I suppose you could use some transparency properties.<br />
<br />
function beforeDrawLegendItem(lerh, bounds, icsc)<br />
{<br />
lerh.getFill().set(255, 0, 0);<br />
}
sgruendel
Hi Virgil,<br />
<br />
<blockquote class='ipsBlockquote' data-author="vdodson"><p>Hi Stefan,<br />
<br />
You can try writing some script into the beforeDrawLegendItem method.<br />
<br />
Read more here: <br />
<a class='bbc_url' href='
http://www.birt-exchange.com/documentation/BIRT_220/ChartJavadoc/chart/api/org/eclipse/birt/chart/script/IChartEventHandler.html'>http://www.birt-exchange.com/documentation/BIRT_220/ChartJavadoc/chart/api/org/eclipse/birt/chart/script/IChartEventHandler.html</a><br
/></p></blockquote>
<br />
great, that does the trick. I simply do lerh.getLabel().setVisible(false); to hide the text, and lerh.getFill().setTransparency(0); to hide the square.<br />
<br />
Many thanks for your help, Virgil!<br />
<br />
<br />
Kind regards, Stefan
Chris605
<blockquote class='ipsBlockquote' data-author="'sgruendel'" data-cid="29680" data-time="1200909916" data-date="21 January 2008 - 03:05 AM"><p>
Hi Virgil,<br />
<br />
<br />
<br />
<br />
great, that does the trick. I simply do lerh.getLabel().setVisible(false); to hide the text, and lerh.getFill().setTransparency(0); to hide the square.<br />
<br />
<br />
Many thanks for your help, Virgil!<br />
<br />
<br />
<br />
Kind regards, Stefan<br /></p></blockquote>
<br />
Hi Stefan,<br />
its an old post, but I hope you'll read it, or perhaps someone else. I have the same problem. I've a chart with two Y-Axis and one series each. I need to group by one of theese series. But now appear in the legend two times the same entries.<br />
The first Y-axis has a square as marker, the seconde no symbol as marker. When i use the two lines of code you mentioned I still kann see the outline of the square marker and the line of second axis (see attached file). But i don't want to hide the legend entries for Y-Axis 1. There should appear the entries from grouping and for Y-Axis 2 should appear only one Entry named "Standard".<br />
<br />
Anyone any ideas?<br />
<br />
Regards, Chris