NEWS

 

 




| Printer Friendly | Post Reply
BIRT Reporting Interactivity
Using BIRT to Develop Interactive Reports

Every organization knows the importance of operational reporting to deliver information to their business users. While traditional operational reports provide a static view into data, BIRT gives end users the ability to drill down to detail, jump to bookmarks, navigate a table of contents, show tool tips, and export data. The article will demonstrate how you can use BIRT to develop rich functionality that gives life and further application value to traditional operation reporting.

Introduction

BIRT is a flexible, 100 per cent pure Java reporting tool for building and publishing reports against data sources ranging from typical business SQL databases, to XML data sources, to in-memory Java objects. BIRT is the Open Source Eclipse Business Intelligence Reporting and Tools project (BIRT) and benefits from the rich capabilities of the Eclipse platform and a very active community of users.

BIRT includes powerful report and chart designers, as well as runtime components for generating and deploying BIRT reports. The BIRT Report Designer provides easy-to-use wizards and point-and-click layout capabilities that are similar to many web page design tools. This unique approach to report creation makes BIRT particularly easy for all levels of developers in an organization. In addition, powerful scripting capabilities and an extensive API allow the Java developer and ISVs to tailor BIRT to specific needs. The runtime component supports the deployment of a variety of reports that, when embedded in an application, adopt the native look and feel of that application. Finished reports are easily integrated with Java Server Pages, servlets, or existing Java applications and leverage existing application server infrastructure.

Requirements to Deploy and Run Examples
  • Eclipse BIRT 2.1
  • Master Report
  • Detail Report
  • Chart Detail Report
  • Classic Cars Sample Database

BIRT Table of Contents

A BIRT Table of Contents (TOC) is a navigational mechanism used to jump to a specific page or record in a report. The TOC is available within the BIRT Viewer and is implemented as a hierarchical tree. When you create a group section in a report, an automatic TOC entry is created for the data value you are grouping on. For example, in the following figure you see a group section for Customer Name and a group section for Order Number. By default, the TOC entry will be the data value for the Customer Name and Order Number respectively. However, it would be nice to see the total order amount at both the customer and order levels. To do this we’ll have to make a minor modification to the TOC expression. We start by editing the Order Number group as shown in Figure 1.

Fig. 1: Edit Group


Editing the group section launches the Group Editor dialog. The TOC Item Expression will need to be modified. You can either click on the ellipses to use the BIRT Expression Builder or simply type the expression directly in the text box. The expression shown in Figure 2 enables the TOC entry to display the total sales order amount as well as the order number.

Fig. 2: Edit Group Dialog—TOC Item Expression


Edit the Customer Name group the same way to display the entire sales amount for all orders placed for each customer. Figure 3 displays the TOC at view time. Clicking on a Customer Name or an Order Number will navigate to that point in the report.


Fig. 3: Table of Contents in BIRT Report Viewer


Bookmarks

A BIRT Bookmark is a navigation ‘landing point’ that is the destination of a hyperlink. Upon clicking the hyperlink, the Web Viewer loads the appropriate page of the target report and scrolls to the defined Bookmark. This target can be specified as the current report, or an entirely different report, located within the application.

The example master report shown in Figure 4 has two sections defined. The first section lists Customer Orders and the second section is a Customer Listing. The Customer Name is displayed in the first section for each of the customer orders. The Customer Listing section of the report contains details for each customer. Linking these two sections is an ideal example of ‘drill to details’ within the same report. As a user of this report scrolls through the orders she may want to get the customer details for the given order. To enable this we start by placing a destination Bookmark on the Customer Name in the second section as shown in Figure 4.


Fig. 4: Creating a Bookmark


The Bookmark expression can be entered either by using the BIRT Expression Builder or by typing the expression directly in the text box. Adding the expression row[“CUSTOMERNAME”] will create a Bookmark for each customer name in the Customer Listing table. This is the landing point for the drill operation and will correspond with the Customer Name in the first section of the report. See Figure 5.


Fig. 5: Bookmark Expression "Customer Name"


After creating the Bookmark, the source for the drill operation is added using a hyperlink within the Customer Orderssection of the report. To do this, click on the Customer Name data item and select Hyperlink in the properties window, as shown in Figure 6.


Fig. 6: Hyperlink Property


Click on the ellipses to display the Hyperlink Options dialog. This type of hyperlink is defined as an Internal Bookmark. By selecting the appropriate radial, the previously created bookmark is available in the Bookmark combo box. Select row[“CUSTOMERNAME”] and click OK.


Fig. 7: Hyperlink Options


Test the report in the BIRT Report Viewer and click on a Customer Name hyperlink in the first section of the report. The Viewer will automatically load the correct page and bookmark containing the details for the selected customer. See Figure 8.


Fig. 8: Testing Hyperlink and Bookmark


Hyperlinks

The previous section described Internal Bookmark hyperlinks. Often the details for a given summary report do not reside within the same report. In this section we’ll investigate the two other types of hyperlink options available in BIRT: URI and Drill-through.

URI

A URI hyperlink allows the report consumer to navigate to a web page, file, servlet, and so on. The report developer can use the BIRT Expression Builder to construct the URI. The construction of the URI can include parameters obtained from the data in the report. For example, if you have a report that includes stock symbols, a URI may be constructed that links to the Yahoo Finance quote page and passes in the stock symbol data value.

URI Hyperlink definition:
”http://finance.yahoo.com/q?s=” + row[“stockSymbol”]

Resulting in:
“http://finance.yahoo.com/q?s=ibm”

Drill-through

A Drill-through hyperlink allows the report consumer to navigate to another BIRT report, passing parameters that the target report can use to execute and display the appropriate data. A good example of this type of hyperlink is where a master report has summary order information and a Drill-through hyperlink on Order Number. When you click on the Order Number Drill-through hyperlink, you are directed to a detail report, passing in the Order Number you clicked on. The detail report uses the passed order number to display a report with detailed order information.

To create this type of hyperlink, select the Order Number data item on the report, choose the hyperlink property in the properties window and click on the ellipses as shown in Figure 9.


Fig. 9: Hyperlink Property


The Hyperlink Options dialog will display. Select the Drill-through hyperlink type. See Figure 10.


Fig. 10: Hyperlink Options Dialog


Under target report, select the report you wish to drill to. The detail report should have been designed to accept a parameter for Order Number. Clicking in the first Parameters cell, under Report Parameters, displays a list of parameters that the target report has available. In the example detail report, there is just one parameter named rptParamOrderNumber; so we choose that parameter as shown in Figure 11.


Fig. 11: Select Parameters


The value to be passed via the parameter is the data row value for Order Number. To enable this, click in the first Values cell and type in the text shown in Figure 12, or click on the ellipses and use the BIRT Expression Builder. Then click OK.


Fig. 12: Parameter Value


To test the Drill-through, preview the report in the BIRT Report Viewer and click on an order number. A detail report should be displayed with the information for the selected order as shown in Figure 13.


Fig. 13: Testing Drill-through Hyperlink


Exporting Data

The BIRT Report Viewer has built-in functionality to save report data in a Comma Separated Values (CSV) format, which subsequently can be opened in Microsoft Excel. There is no design time development required to enable this feature.


Fig. 14: Export Data


Selecting the Export data button on the viewer toolbar will launch the dialog shown in Figure 15, allowing you to select the result set and columns you wish to export.


Fig. 15: Export Data Dialog


After clicking OK you have the option to save the .CSV file or to open in Microsoft Excel. The result of this example is shown in Figure 16.


Fig. 16: Export Data in Excel


Chart Interactivity

BIRT charting supports a wide range of interactive features such as drill through, highlighting, and tool tips. Interactivity within a chart is achieved by setting event type and action pairs on chart elements. A chart element is just a section of the chart such as the legend or an axis. The Interactivity Editor is accessed by selecting the Interactivity button, for the given chart element within the Format tab of the Chart Editor. As an example see Figure 17 for the legend chart element.


Fig. 17: Chart Legend Interactivity Button


The chart elements that are available for interactivity will depend on the type of chart that is used. Most chart types include interactivity on the Chart Area, Chart Title, Legend, Axis lines, Marker lines, and Value Series. When the Interactivity button is pressed the Interactivity Editor is displayed. See Figure 18.


Fig. 18: Chart Interactivity Editor


The list box on the left displays all currently assigned interactive features. The charting engine supports multiple features per chart element, but will only produce one action per event type. The event types supported include Mouse click, Mouse double-click, Mouse down, Mouse over, Mouse move, Focus, Blur, Key down, and so on. The event type is chosen in the Type combo box. The action that the event type will produce is assigned in the Action combo box and includes options for URL redirect, Show ToolTip, Toggle Visibility, Invoke script, Highlight, and so on. Once the Type and Action are chosen, press the Add button to add a new interactive feature to the chart. Using the Update button allows an existing feature to be modified. The Action Details section of the editor is specific to the given action. For example, for a tool tip on the x-axis, Action Details will prompt you to enter the text of the tip.

To use chart interactive features like highlighting and toggle visibility, the chart Output Format on the Select Chart Type tab of the Chart Editor needs to be set to SVG and viewed with an SVG capable browser. To enable SVG output when selecting the preview tab, choose Window->Preferences->Report Design->Preview->Enable SVG chart.

As an illustration, we will add a pie chart to the existing master report. (See the report example for details on the chart design.) The pie chart displays the proceeds received from the top five customers. The chart will support drill through to the customer orders when one of the pie slices is clicked. In addition, we will add a tool tip to the slice that shows the customer contact information with the percentage of company wide proceeds that the customer constitutes. Lastly, the legend will highlight the slice for the given customer.


Fig. 19: Example Chart


The first feature we will add is the tool tip. Select the Value Series item on the Format tab of the Chart Editor. Next select the Interactivity button. For the Type select Mouse Over and for the Action select Show Tooltip. Select the function button to launch the Expression Builder and enter the following:

row["percentoftotal"]+ "% of Company Proceeds\n" +
row["CONTACTFIRSTNAME"] + " " + row["CONTACTLASTNAME"] + "\n"
+ row["PHONE"]



Fig. 20: Chart Tool Tip Design Example


When the results are rendered and the mouse is placed over one of the slices, a display similar to that shown in Figure 21, will be displayed.


Fig. 21: Chart Tool Tip Example


To add highlighting to the legend, select the Interactivity button on the Legend item within the Format tab of the Chart Editor. Next select Mouse Over for the Type and Highlight for the Action. Click the Add button and close the Chart Editor. When previewed and the mouse is moved over the legend item, the corresponding chart slice will be highlighted.

To add drill through from a chart, click the Interactivity button on the Value Series. Select a Type of Mouse Click and an Action of URL Redirect. Under Action Details you can select the Edit base URL button to launch the Hyperlink Options dialog. See Figure 22. Use the Hyperlink Options dialog as described earlier in the article.


Figure 22 Chart Interactivity Editor – URL Redirect


The Interactivity Editor also allows you to add URL parameters. These parameters are appended to the URL that is built in the Hyperlink Options dialog and the values of the parameters are retrieved from the chart. The values that can be passed in this manner are the Category Series, Value Series, and Value Series Name.

In this chart, the Category Series is the Customer Name and the Value Series is the value of the chart data point. So, for example, clicking Muscle Machine Inc would pass a value of 177,913.95. However, the example report does not have a Value Series Name. If we used the optional grouping field on the Select Data tab of the Chart Editor to group by country, then the country would be passed as the Value Series Name.

Each field in the dialog has a text box entry that allows you to name the parameter. For example, if you entered CustomerName in the Category Series text box, &CustomerName=Muscle Machine Inc will be appended to the URL. The actual customer name will be encoded. See Figure 23.


Fig. 23: Chart Editor – Select Data Tab


To build on our example, suppose we have a detail report that displays order and contact information for a given customer. We can set up a drill through to this report from our chart. First, add a URL Redirect on a Mouse Click for the Value Series as described earlier. Select the Edit Base URL button, click the file open icon for the Report Design and Select a target Report and browse to the detail report. Next click OK.


Fig. 24: Hyperlink Options Dialog—Chart Detail


Our Detail report takes the customer name as a parameter. This parameter is defined as CustomerName. Our current chart presents the customer name in the category series, so Under URL Parameter Names on the Interactivity Editor, enter CustomerName in the Category Series text box. See Figure 25.


Fig. 25: URL Parameters


The detail report accepts this parameter and modifies the query for the given customer. See the example for more details. The completed output is presented in Figure 26.


Figure 26 Final Chart Drill Through


Summary

BIRT provides many ways for your business users to interact with application reports. Where traditional reporting ends with static reports, BIRT allows multiple ways to navigate reports via table of contents, bookmarks, and hyperlinks that provide ‘drill to detail’ functionality. BIRT also provides charting interactivity, meaningful tool tip pop-ups, and data exporting capabilities.

Resources & References
  • Eclipse BIRT Project Home Page
  • BIRT Report Designers
  • Eclipse BIRT 2.1 Download
  • Eclipse BIRT Sample Database







 


Yatego Shopping with more than 4000 Shops and with over 1.8 Mio Products. Branchenbuch and over 500.000 Bücher. Inspiration with Themeworld and Technic. A mobilephone- and Handy Shop with Nokia Handy, Motorola Handy and Sony Handy. With our Bestseller easily find Schuhe, Jeans, Kinderschuhe or a Digitalkamera, perhaps a Canon Digitalkamera. More Bestseller: Modellbahn, Diddl and Poker. Find Schmuck or Silberschmuck as easy as an Apple Ipod, Weber Grill or an Akkuschrauber.


  About Us | Advertise | Contact | Feedback | Publisher Copyright © 2007 Software & Support Media.
Any Questions?   Imprint | Privacy Policy