Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Advanced charting in BIRT

Create professional-looking reports with the Eclipse-based Business Intelligence and Reporting Technology

Sheldon Lee-Loy (sleeloy@ca.ibm.com), Staff Software Engineer, IBM
Sheldon Lee-Loy is a BIRT project committer on the BIRT chart engine. He is also a committer on other open source projects focusing on data visualization.
Jane Fang (janefang@ca.ibm.com), Software Engineer, IBM Japan
Jane Fang is a Software Engineer within the Autonomic Computing group at the IBM Toronto Lab. She has been working on Log and Trace Analyzer for Autonomic Computing and related technology for more than three years, and also developed the WEF extension Java library.

Summary:  Since 2004, the Eclipse-based Business Intelligence and Reporting Technology (BIRT) community has grown and gained massive success. This success is growing as more users are starting to integrate with BIRT technology to present business data. A key reason for this success is that users are discovering the rich BIRT reporting components. The BIRT charting capabilities is one of the rich components that allow the end user to uncover trends in data to answer business questions. BIRT provides extensive interactive charting and other advanced features to allow report developers to create professional-looking reports.

Date:  01 Jul 2008
Level:  Intermediate PDF:  A4 and Letter (1193 KB | 43 pages)Get Adobe® Reader®

Activity:  49297 views
Comments:  

Create the overall sales report

We will customize the first report template to create the overall sales report by adding a bar chart to visualize the annual sales of all products from the product line of Classic Models Inc.

Create a dataset

First, we create dataset that will contain the aggregated sales for each product under the classic cars product line. Double-click on overall.rptdesign to open it in the Report Editor. In the Data Explorer view, right-click on Data Sets, then select New Data Set to open the wizard. Type OverallDataSet for the name field and click Next.


Figure 9. Dataset wizard
Dataset wizard

We will construct a SQL statement that will retrieve the product name and the annual sales of each product. The annual sales are calculated by multiplying the product price by the aggregated amounted ordered through the year. In the field on the right-hand side (see Figure 9), type in the following query, then click Finish.


Listing 1. SQL query
                    
select CLASSICMODELS.PRODUCTS.PRODUCTNAME,
sum(CLASSICMODELS.ORDERDETAILS.PRICEEACH \
* CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED) as "sales"
from CLASSICMODELS.ORDERS, CLASSICMODELS.ORDERDETAILS, CLASSICMODELS.PRODUCTS
where (CLASSICMODELS.ORDERS.ORDERNUMBER = CLASSICMODELS.ORDERDETAILS.ORDERNUMBER)
and (CLASSICMODELS.ORDERDETAILS.PRODUCTCODE = CLASSICMODELS.PRODUCTS.PRODUCTCODE)
and (CLASSICMODELS.PRODUCTS.PRODUCTLINE = 'Classic Cars')
group by CLASSICMODELS.PRODUCTS.PRODUCTNAME

You can choose to verify the query by selecting Preview Results.


Figure 10. Preview results
Preview results

Click OK.


Create a bar chart

Next, we will use a column chart to visualize our annual sales. We will use a bar chart and flip the axis to make the product names display horizontally. We will customize the chart by configuring a number of cosmetic attributes to give you an idea of what you can do to change the visual effect of a chart. We will also add customized user interaction on the chart so a message box is displayed when the user clicks on a bar.

To create a bar chart: In the Report Editor, select the second row in the second grid component, right-click and select Insert > Chart, select Bar as the chart type, check the Flip Axis option, leave the default selections for the other fields, then click Next.


Figure 11. Select chart type
Select chart type

Next, we will bind the dataset to our chart. Although we flipped the axis, the x axis will still be the product name, and the y axis will be the sales amount. Click Use Data Set and select OverallDataSet from the drop-down list.


Figure 12. Select data
Select data

Click the Fx button beside the Category (X) Series field. In the Expression Builder, select Available Column Bindings in Category Chart – NewChart, then double-click on PRODUCTNAME to generate row["PRODUCTNAME"] in the expression field. Click OK.


Figure 13. Expression builder
Expression builder

We will use the sales column for the Value (Y) Series. To do that, you can either follow the second step or just drag the header of the sales column from the Data Preview list and drop it in the Value (Y) Series field and click Next.

Now we will change the cosmetic attributes to make the chart look nice. In the tree view on the left-hand side, select Series. Select Value Series for the Color By field. Click the Series Palette button.


Figure 14. Format chart
Format chart

We will fill in the bar with a nice gradient color. In the Series Palette Editor, select the drop-down list and click the Gradient button. Select the start color and end color of your choice. Then click the Close button in the lower-right corner to go back to the Format Chart wizard page.


Figure 15. Series Palette Editor
Series Palette Editor

Now we will format our y axis to indicate that the values we are presenting are dollar amounts. In the tree view on the left-hand side, select Chart Area > Axis > Y-Axis. Click the button beside the Type field to open the Format Editor, select Standard, add the $ in the Prefix field, then click OK.


Figure 16. Edit format
Edit format

Chart grid lines are horizontal or vertical lines extended from axes. They can make a chart easier to read. We will add vertical major grid lines in this chart. Click the Gridlines button, in the Major Grid section, check Visible, select a style you like, then close the editor.


Figure 17. Grid lines
Grid lines

Now we will hide the legend, since it is not needed in this chart. In the tree view, select Chart Area > Legend, uncheck the Visible option, then click Finish to complete the chart. The current chart size is too small. We need to resize it by selecting the lower-left corner of the chart and dragging the mouse pointer until the chart is enlarged to a reasonable size. Use Ctrl+s to save the report.

3 of 13 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source
ArticleID=313710
TutorialTitle=Advanced charting in BIRT
publish-date=07012008
author1-email=sleeloy@ca.ibm.com
author1-email-cc=cappel@us.ibm.com
author2-email=janefang@ca.ibm.com
author2-email-cc=