BIRT currently supports the concept of a multi-view report item. What this means is that two report items share the same data bindings and physical space, but only one is displayed. In the current version of BIRT only tables and crosstabs support this multi-view feature and the second view must be a chart. Generally the view that is displayed is chosen at design time, but this can be altered using some script and a report parameter.
To create a multi-view report item, first create a table or crosstab. Next right click on the report item and select Create Chart View.
This will launch t he Chart Builder. Construct the chart as usual. After creating the chart a second tab will appear at the bottom of the report item.
The tab selected currently determines which view will be displayed. The selected view can also be changed with script and a report parameter. First select the table tab and name the table.
In this case I have named the table “mytable”. Next add a report parameter to use in the script. The parameter should allow two choices, show as chart or show as table. In this example I have named the report parameter ShowAs and the parameter has chartview or tableview as possible values.
Finally enter the following script in the beforeFactory event.
var th = reportContext.getDesignHandle().findElement("mytable");
var mvh = th.getProperty("multiViews");
if( params["ShowAs"].value == "chartview" ){
mvh.setProperty("index", "0" );
}else{
mvh.setProperty("index", "-1" );
}
The first line retrieves a handle to the table and the second retrieves a handle to the multiviews property for the table. The parameter is then used to set the index for the multiview item.
The output will look similar to:
And
This example is available at Birt-Exchange.
3 comments:
hallo,
Congratulations again for the interesting blog.I have onr question that i would like to share with you. I have created a report in java using birt items (especially grids).It is quite good. My problem is that i can not define the position(x,y) inside the grid where i want to add new items(e.g labels or other grids).I have tried setX(),setY() but without result. I also tried to create a free-form but unsuccesfully. Is there something that i could do?
Thank you for your help in advance,
Use grids inside of grids and set their properties like hight and width, and put the labels/data items in the grid.
Hi Jason, great hint. Can you also use the Interactivity Options of the chart to filter the table ?
Post a Comment