It has been said that a picture is worth a thousand words. In the world of reporting, we call these pictures as Charts. With the help of charts, one can present a large amount of data with relative ease, in comparison to presenting with the help of huge data outputs. Charts are useful when used with raw data to drive home points such as percentages, or when used with other charts to build dashboards.
BIRT has an exceptional charting engine. BIRT can create a number of different Chart types, including the tried and tested pie chart, bar chart, and line charts. In addition, there are several other chart types that were extras to BIRT's commercial counterpart such as the Meter Chart and Gantt chart.
In the following sections, we are going to look at building a few different charts centered around employee sales performance. First, we will build a pie chart that will illustrate the top employees based on sales. We will then create a gauge chart that will show the progress an employee has made to meet a quota. Finally, we will create a bar chart that will show sales performance for employees across a time period.
In the following exercise, we are going to look at how to build a pie chart. A pie chart is a very common report type used in business to display percentages. In this example, we will create a pie chart to show what percentage an employee contributed to the total amount of sales. This will give us a visual representation of who the top employees are in terms of sales.
Employee_Sales_Percentage.rptDesign
. ClassicCarsLibrary.rptDesign
library, add the dsClassicCars
data source to the report. totalSales
using the following query:select CLASSICMODELS.EMPLOYEES.EMPLOYEENUMBER, CLASSICMODELS.EMPLOYEES.LASTNAME || ', ' || CLASSICMODELS.EMPLOYEES.FIRSTNAME name, sum(CLASSICMODELS.ORDERDETAILS.PRICEEACH) sales from CLASSICMODELS.EMPLOYEES, CLASSICMODELS.ORDERS, CLASSICMODELS.ORDERDETAILS, CLASSICMODELS.CUSTOMERS where CLASSICMODELS.CUSTOMERS.SALESREPEMPLOYEENUMBER = CLASSICMODELS.EMPLOYEES.EMPLOYEENUMBER and CLASSICMODELS.ORDERS.CUSTOMERNUMBER = CLASSICMODELS.CUSTOMERS.CUSTOMERNUMBER and CLASSICMODELS.ORDERDETAILS.ORDERNUMBER = CLASSICMODELS.ORDERS.ORDERNUMBER and CLASSICMODELS.ORDERS.ORDERDATE between ? and ? group by CLASSICMODELS.EMPLOYEES.EMPLOYEENUMBER, CLASSICMODELS.EMPLOYEES.LASTNAME, CLASSICMODELS.EMPLOYEES.FIRSTNAME
startDate
and endDate
as date types and link them to the two report parameters. Use 2005-01-01
as the startDate's
default value, and 2005-05-01
as the endDate's
default value. totalSales
dataset. SALES
column to the Slice Size Definition and the NAME
column to the Category Definition. To make selecting the correct header easier, we can use the Show data preview checkbox to see what data is in each column. Without it, the preview box will show only the column names.So, we have built a fairly simple report so far. This report is a pie chart with a legend that shows us the employee's color code, with an excerpt that shows us the value of that slice.
While the pie chart we saw in the preceding section is nice, it would be a little easier to view if the slices were exploded, and if the slices had an outline. Let's take a look at how to modify some of the chart's properties to do this.
Things are starting to look better. But let's say we want to change the chart to display percentages instead of numbers and add a little interactivity to the chart to display the sales numbers when a section is clicked on.
valueData
variable into the editor. Surround it with an alert()
method call. It should look like the next screenshot:When we preview the report, the chart pops up, formatted in the manner we want. If we click on one of the pie slices, an alert window will pop up showing the value for that series.