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)
Drop report items based on data
Forty2
Hi,
I need to move and or drop different report items depending on data I gathered from a dataset. All elements are grouped within a single grid. Which script event should I use and how can I access the report items that have all been assigned a unique name?
Regards,
Lukas
Find more posts tagged with
Comments
kclark
Forty2 -- are you just trying to make them invisible based on data from the dataset?
Forty2
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="111035" data-time="1351612205" data-date="30 October 2012 - 08:50 AM"><p>
Forty2 -- are you just trying to make them invisible based on data from the dataset?<br /></p></blockquote>
Unfortunately no...I am working on a report which displays data using charts. However depending on parameters the dataset might not return values for all charts so I need to drop/hide some of them while moving others around to use the maximum available space on the page.
Tubal
I think this would have to be done in your beforeFactory event, and you may not have access to your data at that point.<br />
<br />
You do have access to your report parameters at that point though.<br />
<br />
Something along the lines of:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if(params["myParam"]=="whatever") {
var myElement = reportContext.getDesignHandle().findElement("myWhatever");
myElement.drop();
}</pre>
Forty2
<blockquote class='ipsBlockquote' data-author="'Tubal'" data-cid="111050" data-time="1351630491" data-date="30 October 2012 - 01:54 PM"><p>
I think this would have to be done in your beforeFactory event, and you may not have access to your data at that point.<br />
<br />
You do have access to your report parameters at that point though.<br />
<br />
Something along the lines of:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if(params["myParam"]=="whatever") {
var myElement = reportContext.getDesignHandle().findElement("myWhatever");
myElement.drop();
}</pre></p></blockquote>
The problem is I cannot make the decision based on the parameters since they are merely feed to a database routine which then either returns data to fill all of the charts or only some of them. I am aware of the possibility to hide a graph if there is no data to display, however I also need to move one of the charts in order to fill the gap left by the charts that are hidden.
kclark
How are the charts on the report? One possible solution would be to use create a grid from script and then depending if your chart is hidden you could move the other elements around to the correct spot in the grid. This could be a lot of work though depending on how many object you have in your report.
Forty2
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="111070" data-time="1351690445" data-date="31 October 2012 - 06:34 AM"><p>
How are the charts on the report? One possible solution would be to use create a grid from script and then depending if your chart is hidden you could move the other elements around to the correct spot in the grid. This could be a lot of work though depending on how many object you have in your report.<br /></p></blockquote>
I am merely using a total of 6 charts. They are positioned using a grid that contains two columns. Two of the charts are placed in the left cell while the other 4 are contained in the right cell. However in some cases not enough data is returned to fill all four of the charts on the right. The ones that do not contain data need to be hidden and if none of the four are visible the second chart on the left is to take their place in the cell on the right.<br />
The issue I'm struggling with is that I am unable to find a way to script this i.e. hide the charts and reposition the second chart on the left in case none of the charts on the right display data.
Tubal
<blockquote class='ipsBlockquote' data-author="'Forty2'" data-cid="111077" data-time="1351705816" data-date="31 October 2012 - 10:50 AM"><p>
I am merely using a total of 6 charts. They are positioned using a grid that contains two columns. Two of the charts are placed in the left cell while the other 4 are contained in the right cell. However in some cases not enough data is returned to fill all four of the charts on the right. The ones that do not contain data need to be hidden and if none of the four are visible the second chart on the left is to take their place in the cell on the right.<br />
The issue I'm struggling with is that I am unable to find a way to script this i.e. hide the charts and reposition the second chart on the left in case none of the charts on the right display data.<br /></p></blockquote>
<br />
The issue is that BIRT creates and places the grid and the chart objects before it fetches the data, so there is no simple way to rebuild/move these objects after they are already built and placed.<br />
<br />
It would be possible, like kclark mentioned, to dynamically create a grid and chart objects in the beforeFactory event of your report, but this would also involve scripting your database connections and fetching the data you use to determine if the charts are going to be visible or not in the same beforeFactory script. It's quite an involved process, but it is possible. If this is your only option, and you're adept at scripting, then that's what you'd need to do.<br />
<br />
<br />
You mentioned that you are able to hide charts if there is no data.<br />
<br />
Depending on how you have your charts set up, if you hide the charts you don't need, it should automatically move your remaining charts up in the column. So the only issue would be how to get the bottom left chart to the right side if there are no other charts on the right side?<br />
<br />
One option might be to have two instances of the 2nd chart on the left. One in it's normal place, and the 2nd as the top chart on the right. If you have data in your right side charts, hide the 2nd instance. If you don't, show the 2nd instance and hide the first instance. If that makes sense?
Forty2
Thanks for your quick response!<br />
<blockquote class='ipsBlockquote' data-author="'Tubal'" data-cid="111086" data-time="1351712997" data-date="31 October 2012 - 12:49 PM"><p>
You mentioned that you are able to hide charts if there is no data.<br />
<br />
Depending on how you have your charts set up, if you hide the charts you don't need, it should automatically move your remaining charts up in the column. So the only issue would be how to get the bottom left chart to the right side if there are no other charts on the right side?<br />
<br />
One option might be to have two instances of the 2nd chart on the left. One in it's normal place, and the 2nd as the top chart on the right. If you have data in your right side charts, hide the 2nd instance. If you don't, show the 2nd instance and hide the first instance. If that makes sense?<br /></p></blockquote>
That's the workaround I am using right now. It does the trick but of course having only one chart would be nicer.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'Tubal'" data-cid="111086" data-time="1351712997" data-date="31 October 2012 - 12:49 PM"><p>
It would be possible, like kclark mentioned, to dynamically create a grid and chart objects in the beforeFactory event of your report, but this would also involve scripting your database connections and fetching the data you use to determine if the charts are going to be visible or not in the same beforeFactory script. It's quite an involved process, but it is possible. If this is your only option, and you're adept at scripting, then that's what you'd need to do.<br /></p></blockquote>
I happened to stumble across this <a class='bbc_url' href='
http://www.birt-exchange.org/org/forum/index.php/topic/22742-dataset-value-in-beforefactory-method/'>forum
post</a> just last night so in case I have to redo the report or do something similar I will script the dataset and reorganize the charts as you described.<br />
<br />
Thanks for the help!<br />
Lukas
Forty2
I hope no one minds if I bump this thread again but I have another question regarding this topic.
Is it possible to manually execute a dataset defined in the design and then have BIRT automatically cache and reuse the returned data for other report items that rely on the same data set..?
kclark
If the data is being reused from the dataset in the same report then birt already caches the data for later use for you. If you're trying to cache the dataset to use between different reports then you would need to use a report document. There is a setting for the caching of the dataset but the default is set to cache.
Forty2
What I meant to ask was if BIRT also caches a data set if it is first executed manually by using the data engine directly but also tied to one or more report items?