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)
Can't get legend item to display
elmatador
Hi,<br />
<br />
I've recently written a Line Chart report, and have set the visibility of all of the series on it to hidden.<br />
<br />
Using a list of report parameters, I perform a string-match check on the report parameter item to enable visibility of user-selected series when the report is loaded.<br />
<br />
Unfortunately, this is not causing BIRT to display the series in the legend. It is still invisible there.<br />
<br />
I have ruled out the possibility that the entire legend is not displaying, as I have set a black border to the legend in the Chart GUI. This border shows, but contains no contents.<br />
<br />
Could anyone help? I enclose code which shows my logic for the enabling of the series for visibility, and my attempt to make the legend item also visible.<br />
<br />
I am using BIRT 2.2.<br />
<br />
Thanks,<br />
<br />
Matador<br />
<br />
BEFOREDRAWSERIES:<br />
<br />
//get set of selected series from report params<br />
seriesParam=icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("SeriesArray");<br />
<br />
//set the visibility of the series to true<br />
for (var i=0;i<=seriesParam.length;i++) {<br />
var temp = "" + seriesParam
+ "";<br />
if (temp == series.getSeriesIdentifier()) {<br />
series.setVisible(true);<br />
}<br />
}<br />
<br />
BEFOREFACTORY:<br />
<br />
seriesVis=new Array();<br />
seriesVis=params["rp_seriesvisibility"].value;<br />
reportContext.setPersistentGlobalVariable("SeriesArray", seriesVis);<br />
<br />
<br />
BEFOREDRAWLEGENDITEM:<br />
{<br />
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl); <br />
icsc.getChartInstance().getLegend().getBounds().set(100,100,100,100);<br />
icsc.getChartInstance().getLegend().getInsets().set(0,0,0,0);<br />
lerh.getLabel().getOutline().setVisible(true);<br />
}<br />
<br />
BEFOREGENERATION:<br />
{<br />
chart.getLegend().setVisible(true);<br />
}
Find more posts tagged with
Comments
mwilliams
Hi Matador,
By hiding the series by default, you may have ran into an issue where the item is not created in the legend, therefore, you can't turn the visibility of it back on. Not sure if this is the case or not, though. Have you tried reversing your logic and setting the visibility of the series' to visible by default and making them invisible if they're not in the selected list? If you recreate your issue with the sample database and attach it in here, I can run it and see what you're getting and see if I can find a way to do it.
elmatador
Hi Michael,<br />
<br />
Thanks for your reply! Please find attached the problem reproduced with the classic cars database as requested. <br />
<br />
I've taken your idea of switching them all to visible initially, and then put a setVisible(false) clause in just before the logic that decides if the series should be visible.<br />
<br />
You'll see there is strange behaviour with the legend. Select all the series, and they work. Select only one series, and there seems to be 'slippage' with the legend label, as sometimes you get the wrong label for the series, and other times you get no label at all!<br />
<br />
With Thanks,<br />
<br />
Matador<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>Hi Matador,<br />
<br />
By hiding the series by default, you may have ran into an issue where the item is not created in the legend, therefore, you can't turn the visibility of it back on. Not sure if this is the case or not, though. Have you tried reversing your logic and setting the visibility of the series' to visible by default and making them invisible if they're not in the selected list? If you recreate your issue with the sample database and attach it in here, I can run it and see what you're getting and see if I can find a way to do it.</p></blockquote>
elmatador
Some more observations:
*: It appears that entries are only displayed in the legend if the last item in the array is one of those selected
*: It appears that the labels for the legend items are only correct if ALL the items in the array are selected
*: The only item that gets a label in the legend when it is selected is the last item in the array - however the label is incorrect, as it gives the label name of the FIRST item in the array.
*: Render() for the Legend Block only fires once, on the last series.
I'm confused, and it's starting to look like I'll need to build up the entire legend dynamically and from the ground-up (however you do that!)
mwilliams
Matador,<br />
<br />
This is definitely a bug. I tried to do the same by checking another way than you did and got the same result. I also tried in 2.5. It was the same except when you chose the last item in the array, the legend items for both series' showed up even though one wasn't supposed to. Please file a bug for this at <a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/reportabug.php'>BIRT
: Reporting Bugs and Requesting Enhancements</a>. Include any bug information in here for future reference if you could. Thanks!