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)
Toggle Line Chart series visibility based on Report Parameters
elmatador
Hi All,<br />
<br />
Been at this for over a week and still no joy. I have produced a Line Chart with over 10 different lines on it, and am attempting to use a List Box Report Parameter to enable the user to group-select a subset of these lines for visibility when the report is rendered.<br />
<br />
I have written the following code and pasted it into the beforeDrawSeries() function. Could anyone have a quick look and steer me in the right direction?<br />
<br />
Basically I am trying to get a handle on my chart (Chart1), extract the series and loop through them. I'm trying to get a String match on the name of the item in the List Box, and the name of the Series. Should they match, I wish to set the visibility of the series to visible. I have set the visibility of the series to invisible by default via the Chart GUI.<br />
<br />
The relationship between Chart Objects, Series, SeriesDefinitions and the ilk is a mindfield for me! This represents my first dabble with the Charting API.<br />
<br />
My code follows:<br />
<br />
<br />
function beforeDrawSeries(series, isr, icsc)<br />
{<br />
//get set of selected series from report params<br />
var seriesParam=params["rp_seriesvisibility"];<br />
<br />
//first get handle to the chart (Chart)<br />
var mychart = this.getReportElement( "Chart1" );<br />
<br />
//get the x axis (Axis)<br />
var xAxis =mychart.getAxes().get(0);<br />
<br />
//get the y axis (Axis)<br />
var yAxis = xAxis.getAssociatedAxes().get(0);<br />
<br />
//get the set of Series Definitions from the Y axis (Array)<br />
var seriesDefs = yAxis.getSeriesDefinitions();<br />
<br />
//loop through Series Definition. If contained Series name matches Parameter value,<br />
//set the visibility of the series to true<br />
for (var i=0;i<seriesParam.value.length;i++) {<br />
for (var j=0;j<seriesDefs.value.length;i++) {<br />
if (seriesParam.value
== seriesDefs.get(j).getSeries().getDisplayName()) {<br />
seriesDefs.get(j).getSeries().setVisible(true);<br />
}<br />
)<br />
)<br />
}
Find more posts tagged with
Comments
mwilliams
Hi elmatador,
So, you're wanting the user to be able to select multiple series' from a parameter selection list and display only the ones they've selected in your chart? You've named all your series' and entered those into a static list parameter?
What version of BIRT are you using?
elmatador
Hi,
I'm using v2.2.
Ive managed to get past this issue, but I'm now faced with a new problem - my Legend has disappeared! I've tried the following but no Legend is showing. Can you help?
function beforeDrawLegendItem(lerh, bounds, icsc)
{
//set the legend visibility to true
lerh.getLabel().setVisible(true);
}
function beforeGeneration(chart, icsc)
{
chart.getLegend().setVisible(true);
}