Professional Documents
Culture Documents
Release 11 SP 2
Information in this document is subject to change without notice. Examples provided are fictitious. No part of this document may be reproduced or transmitted in any form, or by any means, electronic or mechanical, for any purpose, in whole or in part, without the express written permission of Actuate Corporation. 1995 - 2011 by Actuate Corporation. All rights reserved. Printed in the United States of America. Contains information proprietary to: Actuate Corporation 2207 Bridgepointe Parkway, San Mateo, CA 94404 www.actuate.com www.birt-exchange.com The slides, supporting text, demonstrations, and exercises presented in this course are provided by Actuate Corporation under an Actuate License agreement. These materials and any accompanying Actuate software, and demonstration and exercise files may be used only in accordance with the terms of the agreement. Actuate software products are protected by U.S. and International patents and patents pending. For a current list of patents, please see http://www.actuate.com/patents. Actuate Corporation trademarks and registered trademarks include: Actuate, ActuateOne, the Actuate logo, BIRT, Collaborative Reporting Architecture, e.Analysis, e.Report, e.Reporting, e.Spreadsheet, Encyclopedia, Interactive Viewing, OnPerformance, Performancesoft, Performancesoft Track, Performancesoft Views, Report Encyclopedia, Reportlet, The people behind BIRT, and XML reports. Actuate products may contain third-party products or technologies. Third-party trademarks or registered trademarks of their respective owners, companies, or organizations include: Adobe Systems Incorporated: Flash Player. Apache Software Foundation (www.apache.org): Axis, Axis2, Batik, Batik SVG library, Commons Command Line Interface (CLI), Commons Codec, Derby, Shindig, Struts, Tomcat, Xerces, Xerces2 Java Parser, and Xerces-C++ XML Parser. Bits Per Second, Ltd. and Graphics Server Technologies, L.P.: Graphics Server. Bruno Lowagie and Paulo Soares: iText, licensed under the Mozilla Public License (MPL). Castor (www.castor.org), ExoLab Project (www.exolab.org), and Intalio, Inc. (www.intalio.org): Castor. Codejock Software: Xtreme Toolkit Pro. DataDirect Technologies Corporation: DataDirect JDBC, DataDirect ODBC. Eclipse Foundation, Inc. (www.eclipse.org): Babel, Data Tools Platform (DTP) ODA, Eclipse SDK, Graphics Editor Framework (GEF), Eclipse Modeling Framework (EMF), and Eclipse Web Tools Platform (WTP), licensed under the Eclipse Public License (EPL). Jason Hsueth and Kenton Varda (code.google.com): Protocole Buffer. ImageMagick Studio LLC.: ImageMagick. InfoSoft Global (P) Ltd.: FusionCharts, FusionMaps, FusionWidgets, PowerCharts. Mark Adler and Jean-loup Gailly (www.zlib.net): zLib. Matt Ingenthron, Eric D. Lambert, and Dustin Sallings (code.google.com): Spymemcached, licensed under the MIT OSI License. International Components for Unicode (ICU): ICU library. KL Group, Inc.: XRT Graph, licensed under XRT for Motif Binary License Agreement. LEAD Technologies, Inc.: LEADTOOLS. Microsoft Corporation (Microsoft Developer Network): CompoundDocument Library. Mozilla: Mozilla XML Parser, licensed under the Mozilla Public License (MPL). MySQL Americas, Inc.: MySQL Connector. Netscape Communications Corporation, Inc.: Rhino, licensed under the Netscape Public License (NPL). Oracle Corporation: Berkeley DB. PostgreSQL Global Development Group: pgAdmin, PostgreSQL, PostgreSQL JDBC driver. Rogue Wave Software, Inc.: Rogue Wave Library SourcePro Core, tools.h++. Sam Stephenson (prototype.conio.net): prototype.js, licensed under the MIT license. Sencha Inc.: Ext JS. Sun Microsystems, Inc.: JAXB, JDK, Jstl. ThimbleWare, Inc.: JMemcached, licensed under the Apache Public License (APL). World Wide Web Consortium (W3C)(MIT, ERCIM, Keio): Flute, JTidy, Simple API for CSS. XFree86 Project, Inc.: (www.xfree86.org): xvfb. All other brand or product names are trademarks or registered trademarks of their respective owners, companies, or organizations.
Contents
Chapter 1 Setup instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Hardware requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Software requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Course materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting up your workstation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Installing Actuate BIRT Designer Professional . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Downloading the exercise files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting started using BIRT Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Importing the exercise files into your workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Reviewing the BIRT Designer Professional user interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 2 2 2 6 6 7 9
Task 4: Edit the query to use a parameter to filter rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Task 5: Bind a data set parameter to a report parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Task 6: Create a title that displays a parameter value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Task 7: Run the report using different parameter values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
ii
Chapter
Chapter 1
Setup instructions
Hardware requirements
Student workstations require Windows in addition to the following requirements:
Software requirements
For this course, the students workstation must run one of the following operating systems:
Windows Server 2008 Windows Server 2003 Windows Vista Enterprise Windows Vista Business Windows XP Pro Windows 7 Actuate BIRT Designer Professional Release 11 Service Pack 2 Adobe Acrobat Reader Adobe Flash Player, available from Adobe at the following URL:
http://www.adobe.com/products/flashplayer/
Course materials
A student must have the following course materials:
2 Introduction to BIRT
4 Run ActuateBIRTDesignerProfessional.exe. InstallShield extracts the necessary files, then displays a welcome page, as shown in Figure 1-1.
Figure 1-1
Welcome screen
Choose Next. 5 Read and accept the license agreement, as shown in Figure 1-2.
Figure 1-2
License agreement
Choose Next. 6 In Prerequisite, choose Next. Then, wait while prerequisite components install. 7 In Setup Type, select Typical, the default setup type, and accept the default destination folder. In Windows 7, this folder is C:\Program Files (x86)\Actuate11\BRDPro. In the other supported Windows operating systems, the destination folder is C:\Program Files\Actuate11\BRDPro, as shown in Figure 1-3.
Figure 1-3
Choose Next. In Windows 7, the installer displays a message instructing you to run Actuate BIRT Designer as an administrator. Choose OK. 8 In License File Details, select the following license option, as shown in Figure 1-4:
Try out the product using the included evaluation software license
Figure 1-4
Choose Next. 9 In Start Copying Files, review the settings, as shown in Figure 1-5.
4 Introduction to BIRT
Figure 1-5
Choose Next. Setup Status indicates how the installation is progressing, as shown in Figure 1-6.
Figure 1-6
Figure 1-7
6 Introduction to BIRT
Figure 1-8
Figure 1-9
Accessing import
2 Choose GeneralExisting Projects into Workspace, as shown in Figure 1-10. Then, choose Next.
Figure 1-10
Figure 1-11
3 In Select root directory, choose Browse. Navigate to the C:\Exercises folder and choose OK. Choose Select All. The projects containing the report designs and other files for this course are selected, as shown in Figure 1-12. Choose Finish. BIRT Designer Professional imports the projects, refreshes the workspace, and builds the workspace.
8 Introduction to BIRT
Figure 1-12
Navigator displays the imported projects, as shown in Figure 1-13. The projects contain the report designs and supporting files that you use in the exercises.
Projects in Navigator
Figure 1-13
This project contains a CSSFiles folder, an images folder, a .project file, and three report designs, as shown in Figure 1-14.
Figure 1-14
2 In the Hyperlinks project, double-click SalesByCountryStart.rptdesign. SalesByCountryStart.rptdesign opens. BIRT Designer Professional displays information in the Report Design views, as shown in Figure 1-15.
View area containing Palette, Data Explorer, and Resource Explorer
Figure 1-15
3 To avoid making changes to the report design, which you use in an exercise, save the design in a new file: 1 Choose FileSave As. 2 In Save As, in File name, type:
Test.rptdesign
Choose Finish.
10 I n t r o d u c t i o n t o B I R T
4 Examine the views that the Report Design perspective displays: 1 Examine the pages available in the report editor, as shown in Figure 1-16. Select each tab in turn, to see the report editor page.
Tab bar containing Layout, Master Page, Script, XML Source, Preview, and Desktop Viewer
Figure 1-16
Layout shows a graphical representation of the report items that define the contents and appearance of a report. Gray lines delimit each report item. Handles delimit the selected item. Container items display an identifying tab as the mouse pointer moves over them. Master page shows a graphical representation of the report items that appear in the header and footer of a report. Script displays an editor that supports writing JavaScript to customize the behavior of a report item. XML Source displays the XML code that defines all the elements in the report design. Preview uses a sample of the available data to display a representation of the report that the design defines.
2 Examine Palette. This view provides all the report items that a report developer can place in the report layout or a master page. To test this functionality, select the layout editor, if necessary. Use the scroll arrows to display all items within a subpalette. Then, drag an item from the palette into the layout, as shown in Figure 1-17.
Scroll arrow
Figure 1-17
3 Select Data Explorer, next to Palette. Examine Data Explorer. This view provides all the data fields that a report developer can use in a report item, either directly or in an expression. Expand Data Sources, Data Sets, and Customers, as shown in Figure 1-18. To test this functionality, drag a data field from Customers into the layout.
11
Figure 1-18
4 Select Resource Explorer, next to Data Explorer. Examine Resource Explorer. This view provides all the shared resources that a report developer can use in a report. Expand System Resources, Flash Object Library, Shared Resources, and images, as shown in Figure 1-19. System Resources includes items available to all report designs. Shared Resources shows shareable items in the current project.
Figure 1-19
5 Select Outline, next to Navigator. Examine Outline. This view provides a hierarchical representation of all the elements in a report design. Expand nodes in the hierarchy, to show their contents, as shown in Figure 1-20. Items within Body appear in the layout editor. If you select an item within the Body hierarchy, the design in the layout editor scrolls to show that selected item.
Figure 1-20
12 I n t r o d u c t i o n t o B I R T
6 Select Property Editor, below the report editor. Examine Property Editor. This view supports setting the values of the most commonly used properties of any element in a report design. Property Editor groups related properties, using a side menu and tabs. Properties for the currently selected report item appear, as shown in Figure 1-21. If no item is selected, the properties of the report design appear. Select tabs at the top of the property editor and items in the side menu to see the available properties for different report items.
Side menu Menu tabs
Figure 1-21
7 Optionally, examine Problems and iServer Explorer views. These views are empty. 5 To close Test.rptdesign, choose FileClose. If a message appears, asking whether you want to save changes, choose No. 6 To delete Test.rptdesign, select Navigator. Right-click Test.rptdesign. Then, choose Delete. In Delete Resources, choose OK. BIRT Designer Professional deletes the test report design.
13
14 I n t r o d u c t i o n t o B I R T
Chapter
Chapter 2
15
Exercise 1
Overview
In this exercise, you create a report that lists customer names, contact names, phone numbers, and countries. The report uses data from the sample database, Classic Models, that is integrated with Actuate BIRT Designer. In this exercise, you become familiar with BIRT Designer and the tools you use to create and preview reports. In this exercise, you perform the following tasks:
Create a new report Build a data source Build a data set Lay out the report to display data Preview the report in different formats Edit and format column headings Review the data bindings Classic Models sample database SimpleListingReport project
Task 1:
Figure 2-1
2 Choose FileNewReport. On New Report, in File name, type the following text:
Customers.rptdesign
3 Choose Finish. If you choose Next instead of Finish, you can select a report template. The default Blank Report template takes effect when you choose Finish. The layout editor displays a blank report.
Task 2:
Before you begin designing a report in the layout editor, you build a data source to connect to an external data repository from which to retrieve data for the report. BIRT Designer can connect to many different types of data sources, such as a flat file, a relational database, or a custom data source defined by program code. Actuate BIRT Designer Professional provides access to more data source types, such as information objects and Java applications. A report design can use multiple data sources. In this task, you create a data source that connects to the Classic Models sample database.
16 I n t r o d u c t i o n t o B I R T
1 Choose Data Explorer. 2 Right-click Data Sources, and choose New Data Source from the context menu. 3 In New Data Source, select Classic Models Inc. Sample Database from the list of data source types, as shown in Figure 2-2.
Figure 2-2
4 In Data Source Name, type the following text, then choose Next:
ClassicModels
Connection information about the new data source appears. 5 Choose Finish. BIRT Designer creates a new data source that connects to the sample database. It appears under Data Sources in Data Explorer, as shown in Figure 2-3.
Figure 2-3
Task 3:
Now, you are ready to build a data set. A data set is a definition of the data to retrieve or compute from a data source. A report design can access multiple data sets defining data from one or more data sources. In this task, you build a single data set to retrieve customer information from the Customers table in the sample database. 1 In Data Explorer, right-click Data Sets, and choose New Data Set. 2 In New Data Set, in Data Set Name, type the following text, as shown in Figure 2-4.
Customers
Data Source Selection shows the data source that you created earlier. Data Set Type indicates that the data set uses a SQL SELECT query.
17
Figure 2-4
Choose Next. 3 In New Data Set, create the following SQL SELECT statement. You can type the query or drag tables and columns from Available Items. Dragging and dropping columns is less error-prone, because the column names are not subject to typographical errors. Just remember to type a comma after every column name except COUNTRY.
select CLASSICMODELS.CUSTOMERS.CUSTOMERNAME, CLASSICMODELS.CUSTOMERS.CONTACTLASTNAME, CLASSICMODELS.CUSTOMERS.CONTACTFIRSTNAME, CLASSICMODELS.CUSTOMERS.PHONE, CLASSICMODELS.CUSTOMERS.COUNTRY from CLASSICMODELS.CUSTOMERS
Figure 2-5
18 I n t r o d u c t i o n t o B I R T
4 Choose Finish to save the data set. Edit Data Set displays the columns you specified in the query, and provides options for editing the data set. 5 Choose Preview Results to ensure the query returns the correct data. You should see the results that are shown in Figure 2-6. These are the data rows that the query returns.
Figure 2-6
6 Choose OK.
Task 4:
In this task, you insert elements in the report to display the data from the data set you created previously. You start by inserting a table element, then you insert data elements in the table. The table dynamically structures all the data rows that the data set returns in a row and column format. 1 Select the palette. Drag a table element from the palette, and drop it in the report in the layout editor, as shown in Figure 2-7.
Figure 2-7
2 In Insert Table, specify a table with 5 columns and 1 detail row. In Data Set, select Customers from the drop-down list as shown in Figure 2-8.
19
Figure 2-8
Table definition
Choose OK. A table appears in the layout editor, as shown in Figure 2-9. The table contains three rows: a header row, a detail row, and a footer row.
Figure 2-9
3 In Data Explorer, expand Customers. 4 Drag CUSTOMERNAME from Data Explorer, and drop it in the first cell in the tables detail row. In the layout editor, the table cell in which you dropped the CUSTOMERNAME field contains a data element that displays [CUSTOMERNAME]. Above this data element is a label element that the layout editor automatically added to the header row. This label displays the field name as static text. It serves as the column heading. 5 Drag CONTACTLASTNAME from Data Explorer, and drop it in the second cell in the detail row. 6 Drag CONTACTFIRSTNAME from Data Explorer, and drop it in the third cell in the detail row. 7 Drag PHONE from Data Explorer, and drop it in the fourth cell in the detail row. 8 Drag COUNTRY from Data Explorer, and drop it in the fifth cell in the detail row. The report should look like the one shown in Figure 2-10.
Figure 2-10
The layout editor showing the table containing label and data elements
In this task, you laid out the report by placing each data set field individually in a table, so that you could explore dragging items from the palette and Data Explorer. A quicker way to achieve the same result is to drag the Customers data set from Data Explorer and drop it in the page. Using this technique, BIRT Designer automatically creates a table with all the fields in the data set.
20 I n t r o d u c t i o n t o B I R T
Task 5:
You can preview a report quickly in the report editor. You can also view the report in the web viewer or in other document formats, such as PDF, DOC, and XLS. 1 Choose Preview, the tab at the bottom of the report editor. The previewer displays the report in HTML format, as shown in Figure 2-11.
Figure 2-11
2 Preview the report in the web viewer. Choose RunView ReportIn Web Viewer. 3 Preview the report in PDF format. Choose RunView ReportAs PDF.
Task 6:
In this task, you edit the text of the column headings and format them to appear left-aligned. 1 Choose Layout to return to the layout editor. 2 Double-click the first column heading, CUSTOMERNAME. 3 Replace the highlighted text with the following text:
Customer
Press Enter. 4 Repeat steps 2 and 3 to change the remaining column headings to the following text:
Contacts Last Name Contacts First Name Phone Country
5 Use Shift+click to select all the column headings. 6 In Property Editor, in PropertiesGeneral, select Left, as shown in Figure 2-12.
Left
Figure 2-12
21
22 I n t r o d u c t i o n t o B I R T
Chapter
Chapter 3
Viewing a report
23
Exercise 2
Overview What you learn What you do
In this exercise, you use Actuate Interactive Viewer to view the first report you created. In this exercise, you learn how to view and manipulate a report using Interactive Viewer. In this exercise, you perform the following tasks:
Run the report View the report using Interactive Viewer Sort the data Group the data Compute and display new values Filter the data
Task 1:
1 In the SimpleListingReport project, open Customers.rptdesign. 2 Choose RunView ReportIn Web Viewer. Actuate Viewer displays the report.
Task 2:
In this task, you switch from the standard viewer to the interactive viewer. 1 Choose the button on the left, as shown in Figure 3-1, to display the main menu.
Figure 3-1
Task 3:
In this task, you sort the data alphabetically by customer name. 1 Click the Customer header.
24 I n t r o d u c t i o n t o B I R T
2 In the toolbar that appears above the header, choose the up arrow icon, as shown in Figure 3-2.
Figure 3-2
Task 4:
In this task, you group the data by country. 1 Right-click the Country header. 2 In the context menu, choose GroupAdd Group, as shown in Figure 3-3.
Figure 3-3
25
Figure 3-4
Task 5:
In this task, instead of displaying contact last names and first names in separate columns, you concatenate the values and display them in one column. 1 Right-click the Contacts Last Name header, then choose ColumnDelete Column. 2 Similarly, delete the Contacts First Name column. 3 Create a new column: 1 Right-click the Customer header, then choose ColumnNew Computed Column. 2 In Calculation, in Column Label, type:
Contact
The dialog displays all the available columns. 2 Choose [CONTACTFIRSTNAME]. 3 Type:
& " " &[
26 I n t r o d u c t i o n t o B I R T
Figure 3-5
4 Choose Validate to check the expression syntax, then choose OK. 5 Choose OK to save the computed column. Figure 3-6 shows the report with the new computed column.
Figure 3-6
Task 6:
In this task, you filter the data to display only customers in USA. 1 Click the Customer header. In the toolbar that appears above the header, choose the filter icon, as shown in Figure 3-7.
27
Figure 3-7
2 In Filter, choose Advanced Filter. 3 In Advanced Filter, specify the following values: 1 In Filter By, select COUNTRY from the drop-down list. 2 In Condition, use Equal To. 3 In Value, choose Select Values, then choose USA from the list of countries. 4 Choose Add Condition. Filters displays the following expression:
COUNTRY = USA
Figure 3-8
Filter condition
Choose OK. The report displays data for USA only. 4 Close the viewer.
28 I n t r o d u c t i o n t o B I R T
Chapter
Chapter 4
Formatting a report
29
Exercise 3
Overview What you learn What you do
Formatting a report
In this exercise, you format a report to improve its appearance. You start with a listing report, CreditLimitByCustomerStart.rptdesign, in the project named ReportFormatting. In this exercise, you learn typical formatting tasks such as setting format properties, applying styles, adjusting the space between elements, and highlighting data based on a condition. In this exercise, you perform the following tasks:
Resize columns Create a report header that includes text and an image Create a new style Import and use predefined styles Replace the display values of a data set field and format text data Adjust the space between report elements Use alternating colors for the data rows CreditLimitByCustomerStart.rptdesign report A cascading style sheet (CSS) file, corporate.css An image file, ClassicLogo.jpg
To complete this exercise, you use the following resources in the ReportFormatting project:
Task 1:
1 In Navigator, open the project named ReportFormatting by clicking the + icon. 2 Open CreditLimitByCustomerStart.rptdesign. 3 Save the report as CreditLimitByCustomer.rptdesign. 4 Preview the report. Figure 4-1 shows the report output.
Figure 4-1
Preview of report
Task 2:
Figure 4-1 shows the default spacing for report elements in a table. A table contains columns of equal width unless you specify explicit column widths. This default behavior can result in poor spacing between columns of data. In this procedure, you resize the columns to improve the layout of data. 1 Choose Layout to return to the layout editor.
30 I n t r o d u c t i o n t o B I R T
2 Select the table by clicking the Table tab located at the lower left corner of the table. This tab appears when you place the cursor over this area. Guide cells appear at the top and left sides of the table, as shown in Figure 4-2.
Table tab
Figure 4-2
3 In the guide cell area, select the right boundary of the first column, and drag it to the right until the tooltip displays a width of 2.5 inches, as shown in Figure 4-3.
Figure 4-3
4 Resize the width of the second column to 1.25 inches, using the columns Width property. 1 Select the guide cell above the Phone column. 2 In Property Editor, select Properties, then General. Set Width to 1.25 in. 5 Use either technique described in step 3 or 4 to resize the third column to 0.75 inches. 6 Preview the report. It should look like the one shown in Figure 4-4. The space between each column of data appears in a more balanced proportion.
Figure 4-4
Task 3:
In this task, you create a report header that displays a company logo, the company address, the report generation date, and a report title.
31
1 Choose Layout to return to the layout editor. 2 Select the table. 3 Right-click the guide cell next to the table header row, then choose InsertRowAbove. You can identify the table header row by its name that appears when you hover the cursor over the guide cell. A new row appears at the top of the table. 4 Insert an image in the first cell of the new row. 1 Drag an image element from the palette, and drop it in the first cell. 2 In Edit Image Item, choose Embedded image. 3 Choose Add Image and navigate to the following folder:
c:\Exercises\ReportFormatting\images
4 Select ClassicLogo.jpg, then choose Open. Edit Image Item displays the image, as shown in Figure 4-5.
Figure 4-5
Image options
5 Choose Insert to add the image to the report. The image displayed in the layout editor is too small. 5 Increase the size of the image. 1 Select the image. 2 In Property Editor, in General, set Width to 2.5 inches and Height to 1.75 inches. 6 Add descriptive text in the header row, using the following steps: 1 To combine the third and fourth columns of the header row, merge those cells. Press Shift, then select the third and fourth cells. Right-click, then choose Merge Cells. 2 Drag a grid element from the palette, and drop it in the merged cell. In Insert Grid, specify a grid with one column and two rows, then choose OK. 3 To resize the grid to fill the cell, drag the handle at the bottom of the grid down to the bottom of the cell, as shown in Figure 4-6.
32 I n t r o d u c t i o n t o B I R T
Handle
Drag to here
Figure 4-6
4 Insert a text element in the first row of the grid. 5 In Edit Text Item, select HTML from the drop-down list of formats that displays Auto, then type the following text:
121 Rue Saint-Charles<BR> Paris, FRANCE 75015
Choose OK. 6 Insert a text element in the second row of the grid. 7 Set the format to HTML, then type the following text:
For internal use only<BR> Report generated on <VALUE-OF format="M/d/yyyy">new Date()</VALUE-OF>
Choose OK. The report design should look like the one shown in Figure 4-7.
Figure 4-7
7 Preview the report. It should look like the one shown in Figure 4-8.
33
Figure 4-8
8 Create a title for the report: 1 In the layout editor, insert a new header row below the row that contains the report header you just finished creating. 2 Merge all the cells in the row. 3 Insert a label element in the cell and type the following text:
Customer List
Press Enter. Preview the report. It should look like the one shown in Figure 4-9.
Figure 4-9
Task 4:
In this task, you format the table header row that displays the column headings by creating a new style with the formatting properties. 1 Choose Layout to return to the layout editor. 2 Select the table. Right-click the guide cell to the left of the table header row that displays the column headings, then choose StyleNew Style. 3 In New Style, select Custom Style, and type the following text as the name of the new style:
columnheading
34 I n t r o d u c t i o n t o B I R T
4 Choose Font, and set the Color to White, as shown in Figure 4-10.
Figure 4-10
5 Choose Background, and set Background color to Black, as shown in Figure 4-11.
Figure 4-11
6 Choose OK to save the style. The row displays the new style. 7 Preview the report. It should look like the one shown in Figure 4-12.
Figure 4-12
35
Task 5:
In this task, you import styles from a CSS file, and apply the styles to report elements you want to format. 1 Choose Layout to return to the layout editor. 2 Right-click anywhere in the report, and choose StyleImport CSS Style. 3 In Import CSS Styles, select the corporate.css file from which to import styles. 1 Choose Browse to find the CSS file in the following location:
C:\Exercises\ReportFormatting\CSSFiles\corporate.css
Choose Open. 2 In Import CSS Styles, choose Select All to select all three styles in the CSS file, as shown in Figure 4-13. Choose Finish.
Figure 4-13
4 In the layout editor, right-click the label that displays the text, Customer List, then choose StyleApply StyleTitle. 5 Preview the report. It should look like the report shown in Figure 4-14.
Figure 4-14
Task 6:
In this task, you replace the numeric credit limit values with credit rating descriptions. For example, credit limits under 50000 display the word Poor instead of the credit limit amount.
36 I n t r o d u c t i o n t o B I R T
1 Choose Layout to return to the layout editor. 2 Select the [CREDITLIMIT] data element. 3 In Property Editor, choose Map. 4 Choose Add to create a mapping rule. In New Map Rule, perform the following steps: 1 Under If following condition is true, choose CREDITLIMIT from the drop-down list. The expression row["CREDITLIMIT"] appears in this field. 2 In the second field, choose Less than or Equal. 3 In the third field, type:
50000
Figure 4-15
5 Choose OK. 5 Add two other map rules: 1 If row["CREDITLIMIT"] Between 50000 and 100000, display Average. 2 If row["CREDITLIMIT"] Greater than or Equal 100000, display Excellent. 6 To better describe the new values, change the label text from Credit Limit to Credit Rank. 7 Preview the report. It should look like the report shown in Figure 4-16. Numeric values under Credit Limit now appear as Poor, Average, or Excellent under Credit Rank.
Figure 4-16
37
Task 7:
The phone numbers in the report are text data in this format: 2035557845. In this task, you format the data so that it appears as 203-555-7845. 1 In the layout editor, select the [PHONE] data element. 2 In Property Editor, choose the Properties tab, then choose Format String. In Format as, select Custom. 3 In Format code, type @@@-@@@-@@@@, as shown in Figure 4-17.
Figure 4-17
4 Preview the report. Each phone number should appear like 203-555-7845.
Task 8:
The report displays very little space between the report title and the main report data. In this task, you increase the space between these sections of the report. 1 Insert a new row below the table header row that contains the report title Customer List. 2 Select the new row, and in General properties, set Height to 0.2 inches. 3 Preview the report. It should look like the one shown in Figure 4-18.
Figure 4-18
38 I n t r o d u c t i o n t o B I R T
Alternatively, you can increase the space after the report title by performing one of the following actions:
Increasing the size of the row that contains the report title. Selecting the label element that displays the report title, and specifying a value for its Padding Bottom property.
Task 9:
A table that displays many rows can be hard to read. A common solution, which you apply in this task, is to set the rows to alternating colors. 1 In the layout editor, select the tables detail row. 2 In Property Editor, choose Highlights. 3 Choose Add to create a formatting rule, and specify the following information in New Highlight: 1 Next to the first field, choose the expression builder button. 1 In the expression builder, select Available Column Bindings, select Table, then double-click RowNum. The following expression appears in the text area:
row.__rownum
row.__rownum returns the current row number. The modulus (%) operator returns the remainder of a division. 2 specifies the number by which to divide. Using this expression, even-numbered rows return 0, and odd-numbered rows return a nonzero value. 3 Choose OK. 2 In the second field, choose Not Equal to. 3 In the third field, type:
0
4 For Background Color, select Silver. Figure 4-19 shows the complete highlight rule.
Figure 4-19
Highlight rule
39
5 Choose OK. 4 Preview the report. The detail rows appear in alternating colors, as shown in Figure 4-20.
Figure 4-20
40 I n t r o d u c t i o n t o B I R T
Chapter
Chapter 5
Using parameters
41
Exercise 4
Overview
In this exercise, you create a report that displays a list of products and the quantities in stock. Rather than display all the products, you design a report to show the products that are low in stock. Because the number at which a stock is considered low can change with time, you create a report parameter that lets you specify the minimum stock threshold when you run the report. In this exercise, you learn how to create a report parameter and how to write a SQL query that is dynamically updated at run time.
What you do
Write a query to return order information for all products Lay out the data Create a report parameter Edit the query to use a parameter to filter rows Bind a data set parameter to a report parameter Create a title that displays a parameter value Run the report using different parameter values
To complete this exercise, you use the ProductListStart.rptdesign report in the ReportParameters report project. This report contains a report header that displays a company name and address, a company logo, and a report title.
Task 1:
1 In Navigator, open the project named ReportParameters, then open ProductListStart.rptdesign. Save the report as ProductList.rptdesign. 2 Choose Data Explorer. Right-click Data Sources, and choose New Data Source. 3 In New Data Source, select Classic Models Inc. Sample Database from the list of data source types. 4 In Data Source Name, type the following text, then choose Next:
ClassicModels
Connection information about the new data source appears. Choose Finish. 5 In Data Explorer, right-click Data Sets, and choose New Data Set. 6 In New Data Set, in Data Set Name, type the following text, then choose Next:
Product List
7 Create the following query. You can type the query or drag columns from the PRODUCTS table under CLASSICMODELS in Available Items and drop them in the text area.
select CLASSICMODELS.PRODUCTS.PRODUCTNAME, CLASSICMODELS.PRODUCTS.QUANTITYINSTOCK from CLASSICMODELS.PRODUCTS order by CLASSICMODELS.PRODUCTS.QUANTITYINSTOCK
Choose Finish. 8 Preview the query results, as shown in Figure 5-1. The rows are sorted on the QUANTITYINSTOCK field, as specified by the order by clause in the query.
42 I n t r o d u c t i o n t o B I R T
Figure 5-1
9 Choose OK.
Task 2:
In this task, you create a layout that displays the data in a simple row-and-column format. You also align the column headings to the left. 1 In the layout editor, drag the Product List data set from Data Explorer, and drop it below the grid that contains the report header information. BIRT Designer creates a table that contains all the data set fields and their corresponding labels, as shown in Figure 5-2.
Figure 5-2
2 In the tables header row, select the PRODUCTNAME and QUANTITYINSTOCK labels. 3 In Property Editor, in PropertiesGeneral, choose Left, as shown in Figure 5-3.
Left
Figure 5-3
43
4 Preview the report. It should look like the one shown in Figure 5-4.
Figure 5-4
Preview of report
Task 3:
In this task, you create a report parameter that prompts the report user to specify a minimum quantity of stock. The report displays only rows where the quantity is less than or equal to the specified value. 1 Choose Layout to return to the layout editor. 2 In Data Explorer, right-click Report Parameters, then choose New Parameter. 3 Specify the following property values for the parameter: 1 In Name, type:
MinQuantity
3 In Data type, select Integer. 4 In Display type, select Text Box. Figure 5-5 shows the complete parameter definition. Choose OK.
Figure 5-5
44 I n t r o d u c t i o n t o B I R T
Task 4:
In this task, you edit the query so that it is dynamically updated at run time to use the report parameter value that the user specifies. 1 In Data Explorer, double-click the Product List data set. 2 Modify the query to add the following WHERE clause:
select CLASSICMODELS.PRODUCTS.PRODUCTNAME, CLASSICMODELS.PRODUCTS.QUANTITYINSTOCK from CLASSICMODELS.PRODUCTS where CLASSICMODELS.PRODUCTS.QUANTITYINSTOCK <= ? order by CLASSICMODELS.PRODUCTS.QUANTITYINSTOCK
The WHERE clause contains a parameter marker, ?, which indicates where you want BIRT to insert the report parameter value.
Task 5:
BIRT creates a data set parameter that corresponds to the parameter marker in the querys WHERE clause. In this task, you modify the data set parameter, and then you bind it to the report parameter. At run time, the data set parameter gets the value from the report parameter and passes the value to the query. 1 In Edit Data Set, choose Parameters. 2 In the Parameters page, select param_1, and choose Edit. 3 In Edit Parameter, specify the following values: 1 In Name, type:
dsp_quantity
2 In Data Type, select Integer. 3 In Direction, use the default, Input. 4 In Linked To Report Parameter, choose MinQuantity from the drop-down list. 5 In Report parameter Update Setting, choose No. 6 Choose OK. Figure 5-6 shows the complete data set parameter definition.
Figure 5-6
7 Choose OK.
Task 6:
In this task, you add a title to the report header. The title displays the report parameter value.
45
1 Drag a text element from the palette and drop it below the label that displays Products List. 2 In Edit Text Item, choose HTML from the drop-down list that displays Auto, then type the following text:
Products with inventory less than <VALUE-OF>params["MinQuantity"].value</VALUE-OF>
The <VALUE-OF> tag enables you to display a dynamic value. The expression params["MinQuantity"].value returns the report parameter value, which you specify when you run the report. 3 Choose OK. Save the report.
Task 7:
In this task, you test that the report returns different data rows when you specify different report parameter values. 1 Preview the report. The parameter prompt, shown in Figure 5-7, displays the prompt text that you specified when you created the report parameter. Type the following value:
1000
Figure 5-7
Enter Parameters
2 Choose Finish to preview the report. Figure 5-8 shows the report.
Figure 5-8
46 I n t r o d u c t i o n t o B I R T
3 Choose Refresh Report to run the report with a different parameter value. 4 Close the report.
47
48 I n t r o d u c t i o n t o B I R T
Chapter
Chapter 6
Using charts
49
Exercise 5
Overview What you learn What you do
Using charts
In this exercise, you create a report that displays several types of charts. The charts are not related to each other. In this exercise, you learn how to create and format various types of charts. In this exercise, you perform the following tasks:
Create a vertical bar chart Create a horizontal bar chart Create a pie chart
To complete this exercise, you use the ChartsStart.rptdesign report in the Charts report project. This report defines the data source and data sets, which the charts use.
Task 1:
In this task, you create a bar chart that displays sales data by territory and by year. This chart uses a predefined data set, Sales By Territory. 1 In Navigator, open the project named Charts, then open ChartsStart.rptdesign. Save the report as Charts.rptdesign. 2 In Data Explorer, right-click the Sales By Territory data set, then choose Edit. Choose Preview Results. As Figure 6-1 shows, the query returns a large number of data rows, more than the preview displays. BIRT displays the following message:
Total 500 record(s) shown. Result contains more records that are not displayed.
By default, a maximum of 500 data rows is displayed in Preview Results and in the report previewer. This setting improves the preview performance as you design and test reports. Later, you change the preview limit of 500 so that you can preview the chart with all the data factored into the totals.
Figure 6-1
3 Choose OK to close the data set. 4 Drag a chart element from the palette and drop it into the layout editor. 5 In New Chart, select the chart type and subtype, as shown in Figure 6-2. 1 Select the bar chart type, the default. 2 Select the Side-By-Side subtype, the first one on the left. 3 Set the dimension to 2D. Choose Next.
50 I n t r o d u c t i o n t o B I R T
Figure 6-2
6 Select the data for the chart: 1 In Select Data, choose Use Data from, and select Sales By Territory from the drop-down list. Data Preview displays several of the data rows returned by the data set. 2 To display the sales data in the y-axis, in Data Preview, right-click the ORDERLINEAMOUNT column, and choose Plot as Value (Y) series. Alternatively, you can drag the column header to the empty field below Value (Y) Series to the left of the Chart Preview. 3 To display the territory data in the X-axis, drag the TERRITORY column header to the Category (X) Series field. Many of the territory values are repeated. Group the data by territory, so that the chart displays only one bar per territory: 1 Choose the Edit group and sorting button to the right of the Category (X) Series field. 2 In Grouping, use the following property values:
Enabled: selected Type: Text Unit: String Interval: 1 Aggregate Expression: Sum. This aggregate function sums the ORDERLINEAMOUNT values for all rows in each territory group. Figure 6-3 shows the grouping options you use. Choose OK.
51
Figure 6-3
4 Group the sales data by year: 1 Drag the ORDERDATE column header to the Optional Y Series Grouping field. 2 Choose the Edit group and sorting button. 3 In Grouping, use the following property values:
Choose OK. Figure 6-4 shows the data specified for the chart.
Figure 6-4
52 I n t r o d u c t i o n t o B I R T
You have completed the minimum definition of a chart. As you design a chart, the Chart Preview portion of the chart editor gives you an indication of the progress you are making. Chart Preview uses sample data, rather than actual data, in the chart. 7 Choose Format Chart. Choose Value (Y) Series. 8 Select Show Series Labels, as shown in Figure 6-5. Each bar in the chart displays a numerical value.
Figure 6-5
9 Choose Finish to save your changes and close the chart editor. 10 Choose Preview. As Figure 6-6 shows, the chart displays data for the NA (North America) territory only. In addition, the design needs additional formatting work.
Figure 6-6
If the chart displays a grey background, the likely cause is that your machine is running Internet Explorer 6 without an SVG plug-in. To eliminate the grey background, change the chart areas background color from transparent to white. Alternatively, you can install the SVG plug-in or upgrade to a later version of Internet Explorer.
53
11 Enlarge the chart. 1 Choose Layout to return to the layout editor, and select the chart. 2 In Property Editor, in PropertiesGeneral, set Width to 7 inches and Height to 3.5 inches. 12 Change the limit on the data rows in the preview from 500 to No limit. 1 Choose Preview. In the previewer, choose Click to Change Preview Preferences. 2 In Preview Row Limits Setting, select No limits on the number of rows to display, as shown in Figure 6-7.
Figure 6-7
3 Choose OK. Choose Yes to close the Confirm Refresh window. The preview should look like the one in Figure 6-8. The series labels are still too crowded.
Figure 6-8
13 Format the chart data. 1 In the layout editor, double-click the chart to open the chart editor. 2 Change the format of the sales number so that 2,171,244.06, for example, displays as 2.2. 1 Choose the Format Chart tab. 2 Choose Value (Y) Series. Choose the Labels button. 3 In Series Labels, select Value Data and choose the Format button. In Edit Format, choose Standard, set Multiplier to 0.000001, and set Fraction Digits to 1. Figure 6-9 shows the formatting options.
54 I n t r o d u c t i o n t o B I R T
Figure 6-9
Format settings
4 Choose OK. Close Series Labels. Chart Preview shows the change. 14 Format the appearance of various parts of the chart. The chart editor displays all the parts of the chart you can format. 1 Edit the sales labels so that they appear inside the bars instead of on top. 1 Choose Value (Y) Series. 2 Choose Labels, and set FormatPosition to Inside, as shown in Figure 6-10. Close Series Labels.
Figure 6-10
2 Edit the title of the chart. 1 Choose Title (under Chart Area) in the list to the left of the chart editor. 2 In Chart Title, type the following title:
Sales By Territory
Choose Apply. The new title appears in the chart preview, as shown in Figure 6-11.
55
Figure 6-11
3 Change the format of the y-axis values so that 2000000, for example, displays as 2M. 1 Choose Y-Axis (under Chart Area) in the list on the left. 2 Choose the Format button to the right of the Type field. 3 In Edit Format, choose Standard, set Multiplier to 0.000001, set Suffix to M, and set Fraction Digits to 0. Figure 6-12 shows the settings. Choose OK.
Figure 6-12
4 Format the legend to display a title and add a border around the legend. 1 Choose Legend (under Chart Area) in the list on the left. 2 Select Visible next to the Title field, then type Year in the field.
56 I n t r o d u c t i o n t o B I R T
3 Choose the Entries button to edit the legend text. 4 In Legend Entries, shown in Figure 6-13, in Text AreaOutline, choose Visible.
Figure 6-13
5 Close Legend Entries. Then, choose Finish to save the report and close the chart editor. 15 Preview the report. Now, it looks readable, like the one shown in Figure 6-14.
Figure 6-14
Task 2:
In this task, you make a copy of the previous chart, then edit the new chart. 1 In the layout editor, select the chart, then copy (Ctrl+C) and paste it (Ctrl+V). A copy of the chart appears after the original chart.
57
2 Double-click the new chart to open it in the chart editor. In the Select Chart Type page, select Flip Axis. The x-axis is now the vertical axis and the y-axis is the horizontal axis, as shown in Figure 6-15.
Figure 6-15
3 Choose Format Chart to format parts of the chart. 1 Edit the sales labels so that they appear at the end of the bars, instead of inside the bars. 1 Choose Value (Y) Series in the list on the left. 2 Choose Labels, and set FormatPosition to Outside. 3 Close Series Labels. 2 Specify a title, Sales, below the horizontal axis. Even though this axis appears to be the x-axis, it is still defined as the y-axis. When you flip axes, the chart is rotated, but the axis definitions remain the same. 1 Choose Y-Axis in the list on the left. 2 Select Visible to the right of Title. In Title, type:
Sales
58 I n t r o d u c t i o n t o B I R T
Figure 6-16
3 Change the color of the background and text in the chart. Instead of a white background and black text, use a dark background and white text. 1 Choose Chart Area, and set Background to a blue color. 2 Set all the text in the chart to white, using a custom style called white-font. For more information about creating a style, see Exercise 3, Formatting a report. Figure 6-17 shows the settings you specify for the chart area.
Figure 6-17
4 Change the color of the axis lines. Choose Axis and set the color of both axes to white, as shown in Figure 6-18.
59
Figure 6-18
5 Change the background color of the chart title. Choose Title, then choose the Layout button. 6 In Title Layout, set the Title Areas Background property to a brown color, as shown in Figure 6-19. Close Title Layout.
Figure 6-19
7 Increase the space between the chart title and the plot area. Choose Plot, then choose the Area Format button. 8 In Area Including Axes, set InsetsTop to 15, as shown in Figure 6-20. This setting adds padding at the top of the plot area. Close Area Format.
60 I n t r o d u c t i o n t o B I R T
Figure 6-20
9 Eliminate the blue background lines around the chart title. Choose Chart Area, scroll down, if necessary and then choose the Outline button. In Outline, set the properties under Inset (Points) to the following values, as shown in Figure 6-21:
Figure 6-21
4 Choose Finish to save your changes. Preview the report. The horizontal bar chart should look like the one shown in Figure 6-22.
Figure 6-22
61
Task 3:
In this task, you create a pie chart that displays sales data by product line. This chart uses a predefined data set, Sales By Product Line. 1 In Data Explorer, open the Sales By Product Line data set, and preview the data rows that it returns. Figure 6-23 shows some of the data rows.
Figure 6-23
Choose OK. 2 In the layout editor, insert a chart after the bar chart. 3 In the chart editor, select the pie chart type, and set dimension to 2D With Depth. Choose Next. 4 Select the data for the chart: 1 In Select Data, choose
Use Data from
3 Drag the PRODUCTLINE column header to the Category Definition field. Each product line represents a category of data, or slice, in the pie chart. 4 Drag the ORDERLINEAMOUNT column header to the empty field under Slice Size Definition. The amounts determine the size of each slice. 5 Many of the product line values are repeated. Perform the following steps to group all the data by product line, so that the chart displays only one slice per product line: 1 Choose the Edit group and sorting button to the right of the Category Definition field. 2 In Grouping, use the following property values:
Enabled: selected Type: Text Unit: String Interval: 1 Aggregate Expression: Sum. This aggregate function sums the ORDERLINEAMOUNT values for all rows in each product line group. Figure 6-24 shows the grouping options you use.
62 I n t r o d u c t i o n t o B I R T
Figure 6-24
3 Choose OK to close Group and Sorting. 6 Choose Finish to save your changes and close the chart editor. 7 In the layout editor, enlarge the chart element, then preview the report. The pie chart should look like the one in Figure 6-25.
Figure 6-25
8 Hide the Series 1 label, which provides no useful information. 1 In the layout editor, double-click the pie chart to open the chart editor. Choose the Format Chart tab. 2 Select Value Series from the list on the left. 3 Choose the Titles button. 4 In Title, deselect Visible, then close the dialog. 9 Format the total sales data. Instead of expressing numbers in dollars and cents format, display numbers in millions. For example, instead of 954,637.54, display 0.95M. 1 Choose the Labels button. 2 Append the product line value to the numeric data and format the value, using the following steps: 1 In Series Labels, in Values, add Category Data. Category Data displays the product line values. Value Data displays the total sales. 2 Using Remove and Add, change the order of items in the Values list to Category Data, followed by Value Data. This order specifies that the labels display the product line name, then the total sales number.
63
3 Use the default Separator value. The comma (,) separates the two values. Figure 6-26 shows the label options you specify.
Figure 6-26
4 In Values, select Value Data from the list of values, then choose the Format button. 5 In Edit Format, specify the format of the numeric data:
Choose Standard. Set Suffix to M. Set Multiplier to 0.000001. Set Fraction Digits to 2.
6 Choose OK to close Edit Format. In the Chart Preview, the label is formatted as Vintage Cars, 0.02M. 10 Close Series Labels. 11 Format other parts of the chart. 1 Now that the value series labels display the product line, the legend is no longer required. Hide the legend. 1 Choose Legend from the list on the left. 2 In Legend, deselect Visible. 2 Change the shape of the pie and the distance between slices. 1 Choose Value Series in the list on the left. 2 In By Distance, type 8. The larger the number, the farther apart the slices. 3 In Pie Ratio, drag the slider to 0.5 to get a more oval shape. Figure 6-27 shows the options you set. A value of 1 results in a round pie, and 0.1 results in a flatter oval.
Figure 6-27
64 I n t r o d u c t i o n t o B I R T
3 Edit the chart title. 1 Choose Title in the list on the left. 2 In Chart Title, type Sales By Product Line 4 Change the color of some of the slices: 1 Choose Series in the list on the left, then choose Series Palette. The Series Palette defines 32 colors by default. To avoid repeating colors, if your pie chart contains more than nine slices, you can add colors. The chart uses colors in order starting from the top of the palette. You can change any of the colors on the palette. 2 Change the first color in the palette from medium blue to a bright blue that is not already in the palette. Click the arrow button on the right of the color, then select another color, as shown in Figure 6-28.
Figure 6-28
5 Close the Series Palette. Choose Finish to save your changes. 12 Preview the report. The finished chart looks like the one shown in Figure 6-29.
Figure 6-29
65
Task 4:
The tube, cone, and pyramid charts are variations of the bar chart. Instead of displaying bars for the Y series, those charts display tubes, cones and pyramids. In this task, you convert the bar chart you created earlier to a tube, cone, and pyramid chart. 1 In the layout editor, double-click the first bar chart in the report. 2 Choose Select Chart Type, then select the tube chart type. 3 Choose Finish. 4 Preview the report. It should look like the one shown in Figure 6-30.
Figure 6-30
Tube chart
5 Convert the tube chart to a cone chart and preview the report. Convert the cone chart to a pyramid chart and preview the report. 6 Close the report.
66 I n t r o d u c t i o n t o B I R T
Chapter
Chapter 7
Using hyperlinks
67
Exercise 6
Overview
Creating hyperlinks
In this exercise, you add hyperlinks to a report that displays sales by country. You create two hyperlinks. The first hyperlink links a country data element to a web page that displays a map of the country. When the report user clicks the name of a country, a Google map of the selected country appears. The second hyperlink links a product data element to another report that displays details about the product. In this exercise, you learn how to create hyperlinks to link a report element to two different types of external documents. In this exercise, you perform the following tasks:
Preview the start report Create a computed column Create a column binding Create a hyperlink to a web page Create a hyperlink to another report
To complete this exercise, you use the SalesByCountryStart.rptdesign and the SalesOfAProduct.rptdesign reports in the Hyperlinks project.
Task 1:
1 In Navigator, expand the Hyperlinks project, then open SalesByCountryStart.rptdesign. 2 Save the report as SalesByCountry.rptdesign. 3 Preview the report. It should look like the one shown in Figure 7-1.
Figure 7-1
Preview of report
Task 2:
Two of the country names listed in the report are abbreviated, UK and USA. Google maps, however, uses full country names. In this task, you create a computed column that maps the abbreviated names to United States of America and United Kingdom. 1 Choose Layout to return to the layout editor. 2 In Data Explorer, double-click the Customers data set. 3 Choose Computed Columns, then choose New. In New Computed Column, specify the following values:
68 I n t r o d u c t i o n t o B I R T
2 In Data Type, select String. 3 In Analysis Type, select Dimension. 4 Choose the expression builder button to the right of the Expression field. 5 In the expression builder, type the following expression:
dataSetRow["LONGCOUNTRY"] = dataSetRow["COUNTRY"]; if (dataSetRow["COUNTRY"] == "UK") dataSetRow["LONGCOUNTRY"] = "United Kingdom"; if (dataSetRow["COUNTRY"] == "USA") dataSetRow["LONGCOUNTRY"] = "United States of America";
6 Choose Validate to check the syntax of the expression. If there are no syntax errors, choose OK. 7 Choose OK. 4 Preview the results of the query. The data rows include the LONGCOUNTRY column and values. 5 Choose OK to save the data set.
Task 3:
A report cannot use the values in a data set field unless a column binding refers to the data set field. In this task, you create a column binding that refers to the computed column you just created. The hyperlink you create in the next procedure uses the column binding to access the values in the LONGCOUNTRY column. 1 In the layout editor, select the table. Figure 7-2 shows the selected table.
Figure 7-2
A selected table
2 In Property Editor, choose the Binding tab. The Binding page displays all the column bindings defined for the table. 3 In the Binding page, choose Add to create a new column binding named LONGCOUNTRY, and specify the following expression:
dataSetRow["LONGCOUNTRY"]
69
Choose OK. Figure 7-3 shows the definition of the new column binding.
Figure 7-3
Task 4:
In this task, you create a hyperlink to open the Google maps web page when the user clicks a country in the report. 1 In the layout editor, select the [COUNTRY] data element in the top group header row. 2 In Property Editor, select the Properties tab, and choose the Hyperlink property. 3 In the Hyperlink page, choose Edit next to the Link To field. 4 In Hyperlink Options, perform the following steps: 1 Choose URI. 2 On the right of the Location field, click the down arrow button next to the ab| label. Choose JavaScript Syntax. 3 In the expression builder, type the following expression:
"http://maps.google.com/maps?q=" + row["LONGCOUNTRY"].replace(" ", "%20")
The expression specifies a URI, which links to Google maps with the long country name passed as a parameter. The JavaScript replace( ) function replaces spaces in the country name with %20, as required in URIs. Choose OK. HyperLink Options displays the expression in Location, as shown in Figure 7-4.
Figure 7-4
70 I n t r o d u c t i o n t o B I R T
Choose OK. 5 Preview the report. All the country names are underlined, indicating they are links. 6 Click a country to test the hyperlink. Figure 7-5 shows the Google maps page that opens when you click Australia.
Figure 7-5
Task 5:
In this task, you link a product code in the current report to a section of another report. The target report, SalesOfAProduct.rptdesign, displays the details of a specified product code. The report uses a report parameter to obtain the product code value at run time. 1 In the layout editor, select the [PRODUCTCODE] data element in the detail row. 2 In Property Editor, choose the Hyperlink property. On the Hyperlink page, choose Edit next to the Link To field. 3 On Hyperlink Options, specify the following values: 1 Choose Drill-through as the hyperlink type. 2 In Report Design, type:
SalesOfAProduct.rptdesign
3 In Report Parameters, perform the following steps: 1 Choose Add. In Add Hyperlink Parameter, specify the following values:
The product code value is passed to the report parameter when the report user clicks the product code hyperlink. 2 Choose OK.
71
4 Use the default values for the other hyperlink options, then choose OK. Figure 7-6 shows the hyperlink options you specify.
Figure 7-6
4 Preview the report. All the product codes are underlined, indicating that they are links. Click a product code to test the hyperlink. Figure 7-7 shows the report that opens and the information in the target report when you click product code S18_1129.
Figure 7-7
72 I n t r o d u c t i o n t o B I R T
Chapter
Chapter 8
73
Exercise 7
Overview
In this exercise, you add a Flash gadget to a report. Flash charts and gadgets add interactivity, animation, and other visual effects to improve report appearance and function. Flash gadgets differ from flash charts in the simplicity of the data they present. Gadgets typically display a single value or a small set of independent values. In this exercise, you learn how to create and format flash gadgets. In this exercise, you perform the following tasks:
Task 1:
In this task, you add a meter gadget to an existing report. A table in the report presents order totals for seven categories, as shown in Figure 8-1. The meter gadget you create uses the same data used in the table, but highlights two key totals only: the total of shipped orders and the grand total of all orders. 1 In Navigator, expand the FlashGadgets project, open OrderStatusStart.rptdesign, and save the report as OrderStatus.rptdesign. 2 Preview the report. It should look like the one shown in Figure 8-1.
Figure 8-1
3 Choose Layout to return to the layout editor. 4 From Palette, drag a flash gadget element and drop it in the grid row shown in Figure 8-2.
Figure 8-2
74 I n t r o d u c t i o n t o B I R T
5 In New Flash Gadget, select the Meter gadget type, as shown in Figure 8-3. Preview displays a meter gadget.
Figure 8-3
Choose Next. 6 Select the data for the gadget. 1 Under Select Data, select Use Data from, then select OrderStatus from the drop-down list. Data Preview shows the columns in the OrderStatus data set. 2 Drag the SHIPPED column to the field on the right side of the Value 1 definition. The expression, row["SHIPPED"], appears in the field, as shown in Figure 8-4. In Preview, the number above the base of the gadgets needle displays 3.03M.
Figure 8-4
Flash Gadget builder displaying the data selected for the meter gadget
75
7 Create a second value for the meter gadget. 1 Click the down arrow button on the right of Value 1, then choose <New Value...>. 2 Drag the TotalOrders column to the field on the right side of the Value 2 definition. Preview shows a second needle in the meter gadget, and 3.27M above the first number. 8 Choose Finish to save the changes to the gadget. Preview the report. It looks like the one shown in Figure 8-5.
Figure 8-5
9 In the layout editor, select the grid cell where you inserted the gadget. In Property Editor, choose PropertiesGeneral, then select Center. Figure 8-6 shows the location of the Center button.
Center
Figure 8-6
Property editor
10 Select the gadget and resize it. In Property Editor, in PropertiesGeneral, set Width to 5 inches and Height to 3 inches.
Task 2:
In this task, you improve the appearance of the gadget. 1 Double-click the meter gadget. In Edit Flash Gadget, select Format Gadget. The Format Gadget page has a preview section in the top half. The bottom half displays formatting properties, which are organized by the parts of a gadget. As you make formatting changes, look at the gadget in Preview to see the effect of each change. 2 Add a color to the background of the gadget. In General, change the background color to light green, as shown in Figure 8-7.
76 I n t r o d u c t i o n t o B I R T
Background color
Figure 8-7
3 Animate the background. 1 Choose the Effects button. 2 In Effect, keep Effect Target set to Background. Choose Add to create a new effect. 3 In Add New Effect, in Name, type:
BackgroundEffect
Choose OK. Effect - BackgroundEffect displays the animation properties. 4 Set the following animation properties, as shown in Figure 8-8:
Select Enable. In Attribute to Animate, select Horizontal Scale. In Start value, select Chart Start X. In Duration, type:
3
77
These properties cause the gadgets background to expand and contract horizontally for three seconds when the gadget first appears.
Figure 8-8
Effect Animation
5 Choose OK. BackgroundEffect appears in the effect list, as shown in Figure 8-9. A symbol under Animation indicates that the effect uses animation.
Figure 8-9
6 Choose OK to return to the Format Gadget page. 4 Change the range of values and the number of tickmarks that the gadget displays. 1 Choose the Scale tab. 2 Set Maximum Value to 5000000. 3 Set Major Tickmarks Count to 10. 4 Set Minor Tickmarks Count to 5. Figure 8-10 shows the Scale properties you set. The gadget displays values from 0 to 5M, rather than values from 0 to 3.3M. As a result, the positions of the needles shift.
78 I n t r o d u c t i o n t o B I R T
Figure 8-10
Scale properties
5 Display the order totals (3.27M and 3.03M) as tooltips instead of displaying them above the base of the needles where they are partially hidden. 1 Choose the Needles tab. The properties for Value 1 appear. Value 1 corresponds to the needle that displays the shipped orders total. 2 In Value, deselect Show Value. 3 Scroll down to the Tool Text property. In Tool Text Value, type the following expression:
"Shipped orders: $" + row["SHIPPED"]
Figure 8-11 shows the properties set for the first needle, Value 1.
Figure 8-11
4 Set the properties of the second needle, which shows the grand total of all orders. Select Value 2 from the drop-down list. 5 Deselect Show Value.
79
7 In Preview, hover the cursor over each needle. Tooltips show the following values:
Shipped orders: $3032204.259999998 Grand Total: $3273280.049999998
8 Edit each needles Tool Text Value expression to use JavaScripts round( ) function to round the numbers to the nearest integer.
6 Change the color of the needles base, also called a pivot. Drawn as a circle, the base is the point around which the needle rotates. 1 Choose the Needle Base/Pivot tab. 2 Set Start Color to Yellow. 3 Change the Rotation to 45 degrees. Figure 8-12 shows the Needle Base/Pivot properties that you set.
Figure 8-12
7 Add a dollar symbol ($) to the numbers displayed by the gadget. 1 Choose the Number Formatting tab. 2 In Prefix, type $, as shown in Figure 8-13.
Figure 8-13
Number Formatting
8 Divide the data plot into three regions to provide more information about the values displayed in the gadget. 1 Choose the Regions tab.
80 I n t r o d u c t i o n t o B I R T
2 Set the values and colors for the regions as shown in Table 8-1.
Table 8-1 Regions properties
Region A B C
The properties for region C are shown in Figure 8-14. In Preview, the meter gadget shows three regions.
Figure 8-14
9 Add a title to the gadget. 1 Choose the AddOns tab. The AddOns options are shown in Figure 8-15.
Figure 8-15
AddOns page
2 Select Text from the list of available types and choose Add. 3 The AddOns -Text page appears. In Name, type Title, as shown in Figure 8-16.
81
Figure 8-16
4 Set the properties shown in Table 8-2. 1 Move the text property page below the gadget Preview window. 2 Choose Apply after setting each property and check how the property appears in the gadget preview.
Table 8-2 Text AddOns Properties
Property Label Start X coordinate Start Y coordinate Font Font weight Font size Font color Text Alignment Horizontal Text Alignment Vertical Text Box Background Color Text Box Border Color Text Wrap Text Wrap Max Width Text Wrap Max Height 5 In AddOns, choose OK.
Value Total of All Orders and Shipped Orders 50% 5% Arial Bold 14 Auto center middle Light yellow Auto Selected 100% 50%
6 Choose Finish in the Flash Gadget builder. 10 Save the report and choose Preview.
82 I n t r o d u c t i o n t o B I R T
The report should look like the one shown in Figure 8-17.
Figure 8-17
83
84 I n t r o d u c t i o n t o B I R T