Reporting with BIRT


In a project I am working on, we need to visualise some information as Reports. I am going to test the main popular tools, so I wanted to share my little “research”.

First tool: BIRT

The Business Intelligence and Reporting Tool (BIRT) project provides the BIRT technology platform to create data visualizations and reports that can be embedded into rich client and web applications.

BIRT is open source and a top-level software project within the Eclipse Foundation.

Pre-requisites

Java 1.6 JDK/JRE (see How to install Java)

MySQL Server (see How to install MySQL)

JDBC Connector (Download it from: http://dev.mysql.com/downloads/connector/j/)

Installing BIRT

There are several ways to get started with BIRT. The fastest way is to download the All-in-one package. This download includes everything you need to start creating BIRT designs, including the full Eclipse SDK.

If we have Eclipse already installed, we can get all the BIRT plug-ins for our existing Eclipse environment. This is our choice.

1) Open Eclipse and go to Help–> Install new software…

Screen Shot 2015-02-11 at 17.57.29

In the Update Manager, give the path to the repository: http://download.eclipse.org/birt/update-site/4.3

You can choose your right version in: http://wiki.eclipse.org/BIRT_Update_Site_URL

Select the plugin you want to install, and follow the steps.

2) Create a Workspace

Once Birt is installed, in order to separate our reporting projects from the eclipse ones – and as a good practice-, we are going to create another workspace.

Go to File –> Switch Workspace –> Other…

Screen Shot 2015-02-11 at 14.44.47

Choose your folder, or write a new one (it will be created) and click on OK.

3) Change Perspective

Go to Windows –> Open Perspective –> Others… and select Report Design.

Screen Shot 2015-02-11 at 14.43.48

4) Create a Project

Now we can start creating a project.

Go to File –> New –> Project

Screen Shot 2015-02-11 at 14.44.16

Select Report Project (You can use the filter to look for it)

Click Next, write the name of the project (in this example: FirstReport) and then Finish.

5) Create a report

Now, we can create a report: File –> New –> Report

Screen Shot 2015-02-11 at 14.45.34

Here, it’s possible to choose the project or parent folder we want to use. Also, we can give a name to the file, e.g mysqlreport.rptdesign.

After click on Finish, we should see something like this:

Screen Shot 2015-02-11 at 14.46.50

6) Create a Data Source

Now it’s time to create a Data Source for our report. In the bottom left corner we can select the Outline Tab, right-click on Data Sources and click on New Data Source.

Screen Shot 2015-02-11 at 14.48.07

7) Setting up the Data Source

Because we are going to use a MySQL database as a Data Source, we select Create from a data source type in the following list. In the list, we click on JDBC Data Source. We can leave the name by default or pick a new one.

Screen Shot 2015-02-11 at 14.49.01

7.1) Add JDBC Connector

After click on Next, we will see the following screen:

Screen Shot 2015-02-11 at 20.36.25

Before, we can give a Driver Class, we must add the MySQL JDBC Connector. In order to do that, we should click on Manage Drivers…

Screen Shot 2015-02-11 at 14.58.39

By clicking in Add…, we can select the JDBC downloaded and extracted from dev.mysql.com (see Prerequisites). Once we have selected the jar file (in this example: mysql-connector-java-5.1.34-bin.jar), we can click on OK.

Screen Shot 2015-02-11 at 20.32.31

Now, we can full the form.

Driver Class: com.mysql.jdbc.Driver (v5.1)
URL: jdbc:mysql://111.111.111.111:3306/sakila
*where 111.111.111.111 is your Server IP. If you are working in a local instance, you may try: 127.0.0.01
User Name: “database user”, e.g. root
Password: ****

Before clicking on Finish, we can test the connection. If we get the a “Connection successful”, we got it.

Screen Shot 2015-02-11 at 15.57.05

8) Create a Data Set

We have created a Data Source, now it’s time to create a Data Set from that source. In the Outline Tab, right-click on Data Set, and then click on New Data Set.

Screen Shot 2015-02-11 at 15.57.32

We select the Data Source we have created before, in Data Set Type, we choose SQL Select Query and finally we give a name to the Data Set.

Screen Shot 2015-02-11 at 15.58.20

In the Query windows we can introduce, visually or by typing, an sql statement.

Screen Shot 2015-02-11 at 16.02.05

At this point, a dummy example is taken: Select * from actor. Don’t worry, we can change it later. Click on Finish and the following screen will appear:

Screen Shot 2015-02-11 at 16.07.45

This is the screen where we can modify our Data Set. We can click on Query and modify the sql statement.

Screen Shot 2015-02-11 at 16.28.29

In this case, we have: Select actor.last_name,count(*) from actor where actor.last_name=’KILMER’. In other words, we want to know how many people have the last name Kilmer. It’s still a dummy example, but for our purposes is enough for now.

9) Add a chart.

Now that we have a Data Set, we can add a chart. Just go to the Palette Tab and double click on Chart. Also, you can drag and drop it where you want.

Screen Shot 2015-02-11 at 16.16.57

The chart builder will appear:

10) Setting up the chart.

10.1 Select Chart Type

Screen Shot 2015-02-11 at 16.17.13

In the Select Chart Type, we we select Bar. Now, we can click on Next button or directly on Select Data tab.

10.2 Select Data

Screen Shot 2015-02-11 at 16.30.39

In Data Preview, click on the last_name column heading, and drag it to the empty Category  (X) Series field. The following expression appears: row[“last_name”]

Repeat the action by selecting the nKilmers column header, and drag it to the empty field in Value (Y) Series.

10.3 Format Chart

Finally we can modify different aspect of the chart format, for instance, the Title: My First Report. After all changes have been made, click on Finish.

Screen Shot 2015-02-11 at 16.31.34

11) Visualizing the report.

By default, we come back to the Layout tab (page). Here, the report is not rendered and we will see a picture like this:

Screen Shot 2015-02-11 at 16.32.15

If we want to see our fantastic report rendered, we can choose Preview and will preview the report in the report editor.

Screen Shot 2015-02-11 at 16.32.06

It was a first approach to BIRT. The following step is how to embed a chart in a web application.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS