Js-Jss 8.2.0 User-Guide 1
Js-Jss 8.2.0 User-Guide 1
SOME TIBCO SOFTWARE EMBEDS OR BUNDLES OTHER TIBCO SOFTWARE. USE OF SUCH EMBEDDED OR BUNDLED TIBCO
SOFTWARE IS SOLELY TO ENABLE THE FUNCTIONALITY (OR PROVIDE LIMITED ADD-ON FUNCTIONALITY) OF THE LICENSED
TIBCO SOFTWARE. THE EMBEDDED OR BUNDLED SOFTWARE IS NOT LICENSED TO BE USED OR ACCESSED BY ANY OTHER TIBCO
SOFTWARE OR FOR ANY OTHER PURPOSE.
USE OF TIBCO SOFTWARE AND THIS DOCUMENT IS SUBJECT TO THE TERMS AND CONDITIONS OF A LICENSE AGREEMENT FOUND
IN EITHER A SEPARATELY EXECUTED SOFTWARE LICENSE AGREEMENT, OR, IF THERE IS NO SUCH SEPARATE AGREEMENT, THE
CLICKWRAP END USER LICENSE AGREEMENT WHICH IS DISPLAYED DURING DOWNLOAD OR INSTALLATION OF THE SOFTWARE
(AND WHICH IS DUPLICATED IN THE LICENSE FILE) OR IF THERE IS NO SUCH SOFTWARE LICENSE AGREEMENT OR CLICKWRAP
END USER LICENSE AGREEMENT, THE LICENSE(S) LOCATED IN THE “LICENSE” FILE(S) OF THE SOFTWARE. USE OF THIS
DOCUMENT IS SUBJECT TO THOSE TERMS AND CONDITIONS, AND YOUR USE HEREOF SHALL CONSTITUTE ACCEPTANCE OF AND
AN AGREEMENT TO BE BOUND BY THE SAME.
ANY SOFTWARE ITEM IDENTIFIED AS THIRD PARTY LIBRARY IS AVAILABLE UNDER SEPARATE SOFTWARE LICENSE TERMS AND
IS NOT PART OF A TIBCO PRODUCT. AS SUCH, THESE SOFTWARE ITEMS ARE NOT COVERED BY THE TERMS OF YOUR
AGREEMENT WITH TIBCO, INCLUDING ANY TERMS CONCERNING SUPPORT, MAINTENANCE, WARRANTIES, AND INDEMNITIES.
DOWNLOAD AND USE OF THESE ITEMS IS SOLELY AT YOUR OWN DISCRETION AND SUBJECT TO THE LICENSE TERMS
APPLICABLE TO THEM. BY PROCEEDING TO DOWNLOAD, INSTALL OR USE ANY OF THESE ITEMS, YOU ACKNOWLEDGE THE
FOREGOING DISTINCTIONS BETWEEN THESE ITEMS AND TIBCO PRODUCTS.
This document is subject to U.S. and international copyright laws and treaties. No part of this document may be reproduced in any form without the
written authorization of Cloud Software Group, Inc.
TIBCO, the TIBCO logo, Jaspersoft, JasperReports, and Visualize.js are registered trademarks of Cloud Software Group, Inc. in the United States and/or
other countries.
Java and all Java based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates.
All other product and company names and marks mentioned in this document are the property of their respective owners and are mentioned for
identification purposes only.
THIS DOCUMENT IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
THIS DOCUMENT COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY
ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THIS DOCUMENT. TIBCO
SOFTWARE INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN
THIS DOCUMENT AT ANY TIME.
THE CONTENTS OF THIS DOCUMENT MAY BE MODIFIED AND/OR QUALIFIED, DIRECTLY OR INDIRECTLY, BY OTHER
DOCUMENTATION WHICH ACCOMPANIES THIS SOFTWARE, INCLUDING BUT NOT LIMITED TO ANY RELEASE NOTES AND "READ
ME" FILES.
This and other products of Cloud Software Group, Inc. may be covered by registered patents. Please refer to Cloud Software Group's Virtual Patent
Marking document (https://www.tibco.com/patents) for details.
Copyright © 2005-2023. Cloud Software Group, Inc. All Rights Reserved.
1.1 Introduction
Jaspersoft Studio is an Eclipse-based report designer for JasperReports Library and JasperReports Server; it's
available as an Eclipse plug-in or as a stand-alone application. Jaspersoft Studio allows you to create sophisticated
layouts containing charts, images, subreports, crosstabs, and more. You can access your data through a variety of
sources including JDBC, TableModels, JavaBeans, XML, Hibernate, Big Data (such as Hive), CSV, XML/A, as
well as custom sources, then publish your reports as PDF, RTF, XML, XLSX, CSV, HTML, XHTML, text,
DOCX, or OpenOffice.
JasperReports® Server builds on JasperReports® Library as a comprehensive family of Business Intelligence (BI)
products, providing robust static and interactive reporting, report server, and data analysis capabilities. These
capabilities are available as either stand-alone products, or as part of an integrated end-to-end BI suite utilizing
common metadata and provide shared services, such as security, a repository, and scheduling. The server exposes
comprehensive public interfaces enabling seamless integration with other applications and the capability to easily
add custom functionality.
This section describes functionality that can be restricted by the software license for JasperReports Server. If
you don’t see some of the options described in this section, your license may prohibit you from using them. To
find out what you're licensed to use, or to upgrade your license, contact Jaspersoft.
The heart of the Jaspersoft® BI Suite is the server, which provides the ability to:
• Easily create new reports based on views designed in an intuitive, web-based, drag and drop Ad Hoc Editor.
• Efficiently and securely manage many reports.
• Interact with reports, including sorting, changing formatting, entering parameters, and drilling on data.
• Schedule reports for distribution through email and storage in the repository.
• Arrange reports and web content to create appealing, data-rich Jaspersoft Dashboards that quickly convey
business trends.
For users interested in multi-dimensional modeling, we offer Jaspersoft® OLAP, which runs as part of the server.
While the Ad Hoc Editor lets users create simple reports, more complex reports can be created outside of the
server. You can either use Jaspersoft® Studio or manually write JRXML code to create a report that can be run in
the server. We recommend that you use Jaspersoft Studio unless you have a thorough understanding of the
JasperReports file structure.
You can use the following sources of information to learn about JasperReports Server:
• Our core documentation describes how to install, administer, and use JasperReports Server and Jaspersoft
Studio. Core documentation is available in PDF format on the Product Documentation website. You can also
access PDF and HTML versions of these guides online from the Documentation section of the Jaspersoft
Community website.
• Our Ultimate Guides document advanced features and configuration. They also include best practice
recommendations and numerous examples. You can access PDF and HTML versions of these guides online
from the Documentation section of the Jaspersoft Community website.
• Our Online Learning Portal lets you learn at your own pace, and covers topics for developers, system
administrators, business users, and data integration users. The Portal is available online from the Professional
Services section of our website.
• Our free samples, which are installed with JasperReports Library, Jaspersoft Studio, and JasperReports Server,
are available and documented online. Please visit our GitHub repository.
• If you have a subscription to our professional support offerings, please contact our Technical Support team
when you have questions or run into difficulties. They're available on the web at and through email at
http://support.tibco.com and [email protected].
JasperReports Server is a component of both a community project and commercial offerings. Each integrates the
standard features such as security, scheduling, a web services interface, and much more for running and sharing
reports. Commercial editions provide additional features, including Ad Hoc views and reports, advanced charts,
dashboards, Domains, auditing, and a multi-organization architecture for hosting large BI deployments.
1.2.1 Requirements
/S Silent mode (optional) Flag to run the installer in silent mode. When /S is present, no prompt is
required from the user.
/LICENSE License Path (optional - Path to the license file to use for this installation. The license file is copied into
commercial versions the Jaspersoft Studio installation folder and given the following filename:
only) Jaspersoft-JSS.license. If no license is specified, Jaspersoft Studio looks for
the file Jaspersoft-JSS.license in the installation directory.
If this option is specified it must appear before the /D option.
You can place the license file there directly instead of using the /LICENSE
option.
Destination Directory
/D The path of the installation directory for this Jaspersoft Studio instance.
(Mandatory)
\JASPERSOFT\Installer\TIBCOJaspersoftStudioPro-x.x.x.final-windows-installer-x86_64.exe /S
/LICENSE=C:\Jaspersoft\My Licenses\jasperserver.license /D=C:\SW\JASPERSOFT\JSS\xxx
The command-line installer looks for the license in the following order:
1. (Optional) If the command is executed including the /LICENSE option, the license at the specified
path will be copied into the installation folder with filename Jaspersoft-JSS.license.
2. Jaspersoft Studio will look in the installation folder for a license with name Jaspersoft-JSS.license .
3. If no license is present, the evaluation license is used.
If you are not prompted to update your workspace, you do not need to.
If you are updating from an old version of Jaspersoft Studio, you are prompted to choose a new workspace when
you launch Jaspersoft Studio. When you choose a new workspace, a new, empty workspace is created and set as
the workspace for your Jaspersoft Studio instance. This workspace will be used for newer versions. Your previous
workspace remains unchanged and can still be used with older versions.
To update the reports and data from your earlier version of Jaspersoft Studio, you can import some or all of your
projects, server connections, data adapters, and project settings into your new workspace.
Importing projects:
1. (Optional) To import a version of the MyReports project, you must first delete the existing MyReports folder
from your current workspace. You can do this, for example, if you have just upgraded and have created a new
empty workspace. To delete MyReports in your current workspace, navigate to the workspace location in your
file system and delete or move the MyReports directory.
2. Select File > Import ...
3. Select Existing Projects into Workspace from the General category.
4. Browse to the workspace which you want, click OK, and then click Next.
The Import dialog opens.
5. To work on a copy without modifying the originals, select Copy projects into workspace.
6. Click Finish.
The projects you selected are imported into your current workspace.
Your workspace contains server connections, global data adapters, and your Jaspersoft Studio preferences in
addition to your projects. You must import each type separately.
4. Choose the data adapters you want. You do not need to import the built-in adapters (One Empty Record and
Sample DB).
5. Click Next.
always a risky operation, but it was still valid because the user was not using a new tag in the XML. With the move
to an XML schema, the JRXML output of iReport 3.1.1 and newer can only be compiled with a JasperReports 3.1.0
or later. All versions of Jaspersoft Studio produce output that is only compatible with later versions of
JasperReports Library.
For information on exporting or compiling a report to an earlier version of JasperReports Library, see 26.7,
“Setting Compatibility with Earlier Versions of JasperReports Library,” on page 483.
3. Edit the Jaspersoft Studio Professional.ini file appending the following two Java properties
(replace with the proper WebView files location):
-Dorg.eclipse.swt.browser.DefaultType=edge
-Dorg.eclipse.swt.browser.EdgeDir=C:\\dev\\webview
If the Edge browser configuration is missing, the following warning is displayed in the bottom toolbar of the
JRXML editor.
Edge browser engine is not setup. HTML and JRIO Preview will not work fine.
2. Select the Coffee template and click Next. The New Report Wizard shows the Report file page.
3. Navigate to the folder you want the report in and name the report. To create a new folder, see “Creating a
Project Folder” on page 31.
4. Click Next.
The New Report Wizard displays the Data Source page. This is where you choose the data that will fill
the report.The drop-down menu shows the pre-installed data adapters as well any data adapters you have
added. The following adapters are pre-installed:
• One Empty Record - Empty rows: Data adapter that lets you create a report without data. You might
use this option to define the layout of a report and connect it to a data source later.
• Sample DB - Database JDBC Connection: Data adapter that connects to an SQL database provided
with the Jaspersoft Studio installation. If you are getting your data from a JDBC database, you must also
supply an SQL query.
You can create a data adapter separately or click New... to create a data adapter directly from this dialog.
Adapters can be created globally (embedded in the workspace) or local to a specific project. Using a local
adapter makes it easier to deploy the report to JasperReports Server. See 10.1, “Creating and Editing
Data Adapters,” on page 144 for more information.
5. Choose Sample DB - Database JDBC Connection. With a JDBC connection, the Data Source dialog
shows the database schema on the left and your query on the right.
6. Enter the query SELECT * FROM ORDERS on the right. Note that you can view your query in three different
ways: as text, as an outline, or as a diagram.
7. Click Next. The Fields window is displayed. The Dataset list shows all the discovered fields.
8. Select the following fields and click the right arrow to add them to your report.
• ORDERID
• SHIPNAME
• SHIPADDRESS
• SHIPCITY
• SHIPREGION
9. Click Next. The Grouping window is displayed. You do not want any grouping for this report.
10. Click Next and Finish.
Jaspersoft Studio now builds the report layout with the selected fields included as shown.
3. Add more fields by clicking the Read Fields button. All the fields discovered are added as new fields in the
report.
You can also change your query in the same dialog. If a new query discovers fewer fields than used in the
existing report, the fields not included the new query are removed from your report.
6. To add a field to your report, click the field and drag it into the Design.
When the field object is dragged inside the detail band, Jaspersoft Studio creates a text field element and sets
the text field expression for that element.
Each subreport is saved in a separate report file. Reflecting standard Eclipse design, saving or previewing a
report that contains subreports does not update the subreports. When you edit a subreport, you must first
build the subreport and then save the file in order for the subreport changes to be visible when you preview
the report that contains it.
• To build a subreport explicitly, use the Build All button on the toolbar, or type Ctrl-B. Alternatively, select
Project > Build Automatically to have Jaspersoft Studio do it for you.
• To save a subreport, use File > Save or File > Save As.
2. Enter Jasper in the Wizards bar to filter actions to those related to Jaspersoft Studio
3. Select JasperReports Project. Click Next. The New JasperReports Project wizard appears.
4. Enter a name for your project and click Finish. The Project Explorer displays your project.
• The Outline view shows the complete structure of the report in a tree. When the Design or Source tab is active,
clicking an element in the Outline view highlights that element in the editor. The Outline tab is empty when
the Preview tab is active.
• The Properties view lets you view and edit the properties of the element that is currently selected in the report
editor or in the Outline view. The properties shown depend on the type of element. For example, the Properties
view for a table shows four tabs: Appearance, Dataset, Table, and Advanced, while the Properties view for a
line shows Appearance, Borders, Line, Inheritance, and Advanced. Some properties are read-only, but most are
editable. When the root node of a report is selected in Outline view, the Properties view shows the properties
for the report.
Unlike many other views, you can open multiple instances of the Properties view at one time and you can pin a
selection to a specific Properties view instance. This allows you to view or edit the properties for a specific
element while working with other elements in your report, or with another report entirely.
• The Problems view shows a list of problems and errors that can, for example, block the correct compilation of
a report.
• The Report state summary provides statistics on report compilation/filling/execution. Errors are shown here as
well.
This comparison table shows the differences in terminology between iReport and Jaspersoft Studio.
instance, the page header is repeated at the beginning of every page, while the detail band is repeated for each
record.
Jaspersoft Studio provides a graphical interface for creating JRXML files. The layout is visual, so you can ignore
the underlying structure of the JRXML. You can specify the precise page locations of different types of text and
data, such as title, footers, detailed records, groups, and summary information. Some portions of a page defined in
this way are reused, others stretch to fit the content, and so on. Additional tools let you add charts and subreports,
set up an optional query retrieve data out of a data source, and more.
Title The title band is the first visible band. It is created only once and can be printed on a separate
page. It is not possible during design to exceed the report page height (top and bottom margins
are included). If the title is printed on a separate page, this band height is not included in the
calculation of the total sum of all band heights.
Page Header The page header band allows you to define a page header. The height specified during the
design phase usually does not change during the creation process, except for the insertion of
vertically resizable components such as text fields. The page header appears on all printed
pages in the position defined during the design phase. Title and summary bands do not include
the page header when printed on a separate page.
Column Header The column header band is printed at the beginning of each detail column. Usually labels
containing the column names of a tabular report are inserted in this band.
Group Header A report can contains zero or more group bands which permit the collection of detail records in
real groups. A group header is always accompanied by a group footer (both can be
independently visible or not). Different properties are associated with a group. They determine
its behavior from the graphic point of view. It is possible to always force a group header on a
new page or in a new column and to print this band on all pages if the bands below it overflow
the single page (as a page header, but at group level). It is possible to fix a minimum height
required to print a group header: if it exceeds this height, the group header band is printed on a
new page (please note that a value too large for this property can create an infinite loop during
printing).
Group Footer The group footer band completes a group. Usually it contains fields to view subtotals or
separation graphic elements, such as lines.
Column Footer The column footer band appears on at the end of every column. Its dimension are not resizable
at run time (not even if it contains resizable elements such as subreports or text fields with a
variable number of text lines).
Page Footer The page footer band appears on every page where there is a page header. Like the column
footer, it is not resizable at run time.
Last Page If you want to make the last page footer different from the other footers, it is possible to use the
Footer special last page footer band. If the band height is 0, it is completely ignored, and the layout
established for the common page is used for the last page.
Summary The summary band allows you to insert fields containing total calculations, means, or any other
information you want to include at the end of the report.
Background The background enables you to create watermarks and similar effects, such as a frame around
the whole page. It can have a maximum height equal to the page height.
Letter 612x792
Note 540x720
Legal 612x1008
A0 2380x3368
A1 1684x3368
A2 1190x1684
A3 842x1190
A4 595x842
A5 421x595
A6 297x421
A7 210x297
A8 148x210
A9 105X148
A10 74X105
B0 2836x4008
B1 2004x2836
B2 1418x2004
B3 1002x1418
B4 709x1002
B5 501x709
ARCH_E 2592x3456
ARCH_D 1728x2593
ARCH_C 1296x1728
ARCH_B 864x1296
ARCH_A 648x864
FLSA 612x936
FLSE 612x936
HALFLETTER 396x612
11X17 792x1224
LEDGER 1224x792
By modifying width and height, it is possible to create a report of whatever size you like. Although Jaspersoft
enables you to create pixel-perfect reports, the page orientation options, Landscape or Portrait, are there because
they are used by certain report exporters. The page margin dimensions are set by means of the four options on the
Page Margin tab.
3.5.1 Columns
Pages, one or more of which make up a report, present bands that are independent from the data (such as the title or
the page footers) and other bands that are printed only if there are one or more data records to print (such as the
group headers and the detail band). These last sections can be divided into vertical columns in order to take
advantage of the available space on the page. A column does not concern the record fields, but it does concern the
detail band. This means that if you have a record with ten fields and you desire a table view, ten columns are not
needed. However, the element must be placed correctly to have a table effect. Ten columns are returned when long
records lists (that are horizontally very narrow) are printed.
Next, let's set up columns in a report as an example. Create a new report from File > New > Jasper Report.
Choose as template BlankA4 and name it ColumnExample. Use Sample DB - Database JDBC Connection
for the data adapter, with the following SQL query: select * from orders. Fields from the database are
discovered. Double-click SHIPNAME, to add it to the report field and click Next twice. Finally, click Finish.
From the outline view drag the SHIPNAME field in the report in the detail band, resize the detail band, and remove
the unused bands. Go to the Preview tab to see the compiled report.
By default the number of columns is 1, and its width is equal to the entire page, except the margins. The space
between columns is zero by default. Most of the page is unused. If multiple columns are used, this report would
look better. On the Page Format dialog set the number of columns to two and compile the report to see the changes.
Jaspersoft Studio automatically calculates maximum column width according to the margins and the page width. If
you want to increase the space between the columns, increase the value of the Space field.
The restricted area is used to mark every column after the first, to show that all the elements should be placed in
the first column; the other columns are replicated automatically during compilation. If you want you can also put
elements in the other columns, but in most cases you need only the first. It is not recommended that you use parts
of the report as margins and columns after the first, if they have to be considered as though they were a
continuation of the first.
Multiple columns are commonly used for print-outs of very long lists (for example, a phone directory). It is
important to remember that when you have more than one column, the width of the detail band and of linked bands
is reduced to the width of the columns.
The sum of the margins, column widths, and space between columns has to be less than or equal to the page width.
If this condition is not met, the compilation results in an error.
• Export a sample image – Saves a PNG file of the current page of the report in a location you specify.
• Export report – Saves the report to a file in the format you specify from the drop-down list.
• Show parameters – Expands the parameters panel.
• Parameters panel. Automatically displayed for a report that has parameters that have been specified for
prompting; otherwise it is hidden. You can display or hide the parameters pane using the expand/collapse
arrows to the right of the panel or show it by clicking on the Preview menu. Use the following icons to
choose what is displayed in this panel:
• Input parameters – Shows any input parameters that are set for prompting and lets you manually enter
values.
• Report parameters –Shows all parameters for the report.
• Sort fields – Shows any fields set for sorting.
• Export options – Displays any export properties set at the report level. Click the down arrow to open
the Properties dialog for Jaspersoft Studio and see the export properties set at the Jaspersoft Studio level.
• Bookmarks – Lists the bookmarks set in the report.
• Pin Parameters Panel – Click this to have the parameters panel display for all reports.
• Report preview.
In some cases, bugs in the export format may result in issues in the final output. For example, some versions
of Microsoft Word incorrectly render borders on a table element exported to DOCX (the left top and bottom
borders are missing). You may be able to find a workaround based on the output format. For example for the
Microsoft Word bug, you might try the following:
1. In Jaspersoft Studio, create a style named Table_Padding, with 1-pixel left and right padding.
2. Apply this style to each table element in the report.
• The Appearance tab allows you to set the location, size, color, and text style of the element.
• The Borders tab allows you to set the padding and border style, color, and width of the element.
• An element tab allows you to set evaluation time along with properties specific to the element type. For
example:
• The Static Text tab allows you to define unchangeable text for a field, and control its appearance.
• The Text Field tab allows you to format and position a text field element.
• The Image tab allows you to set image alignment, fill, and scale properties.
Some elements have more than one element-specific tab. For example, the Chart component has the Chart and
Chart Plot tabs, and the Map component has the Map, Authentication, Markers, and Paths tabs.
• The Inheritance tab allows you to view any attributes inherited from another level, and override those
attributes when possible.
• The Hyperlink tab, available for image, text field, and chart elements, allows you to define a hyperlink in an
element.
• The Advanced tab displays detailed information about the element.
Frequently, the value of an attribute is undefined, and it has a common default value. This means that the element
does not have a specific behavior defined, but gets a behavior from somewhere else. For example, the default value
of the attribute "background color" is undefined in most of cases, but when a non-transparent element is added to a
report in the design tab, you can see that it has a white background. The value of the background color attribute is
inherited from a lower level.
• Click on the element in the palette. The cursor changes to show that an element is selected. Click and drag
in the report editing area to size and place the element. If you insert a crosstab or table using click and drag,
the columns fill the whole crosstab or table.
4.2.3.3 Guides
When dragging or resizing an element, Jaspersoft Studio suggests places to align it based on the elements currently
in the Design tab, the band bounds, and any guides. When the element you're moving or resizing is in line with
another element in the report, a guideline appears, allowing you align the elements. To force elements to align with
guidelines, select View > Snap to Guides from the main menu.
You can drag and change the position of a guideline at any time with no effect on the element’s position.
To remove a guideline, drag it to the upper-left corner of the report editing area.
When grid layout is selected for a container, such as a band, elements inside the container have a Layout section on
the Appearance tab of the Properties dialog. The following table shows the properties you can set on a element in a
container with grid layout. The property name to use in source view is included in the description.
Row Relative (default) or an Number of the row from which this element starts. 0 is the first row.
Number integer between 0 and When set to Relative, increments the last evaluated row by 1.
1000
com.jaspersoft.layout.grid.y
Column Relative (default) or an Number of the column from which this element starts. 0 is the first
Number integer between 0 and column. When set to Relative, increments the last evaluated column
250 by 1.
com.jaspersoft.layout.grid.x
Row Span Integer between 0 and Number of rows that the element spans.
1000; default = 1
com.jaspersoft.layout.grid.rowspan
Column Integer between 0 and Number of columns that the element spans
Span 250; default = 1
com.jaspersoft.layout.grid.colspan
Fixed Size Boolean; default = false. Set to true to manually size the element. Set to false to have the
element size automatically using the element's settings
com.jaspersoft.layout.grid.fixed
Row Number; default = 1 Number that specifies how much space the element's row takes
Weight relative to other rows. Not available when Fixed Size is True.
com.jaspersoft.layout.grid.weight.x
Column Number; default = 1 Number that specifies how much space the element's column takes
Weight relative to other rows. Not available when Fixed Size is True.
com.jaspersoft.layout.grid.weight.y
6. Right-click in a blank space in the Title band and select Arrange in Container > Grid Layout, or select the
Title band and select Grid Layout in the Properties view.
The two elements are arranged to fill the band equally.
7. Resize the elements so that the chart takes up most of the space. To do this, select the chart. In Properties
view, in the Layout section of the Appearance tab, set Column Weight to 5.
The elements adjust so that the chart width is five times the image width.
8. Now add a static text element to the far right of the title band.
The static text is added at the end of the first row.
9. Position the static text. To do this, select the static text. In Properties view, in the Layout section of the
Appearance tab, set the following:
• Set Row Number to 1 to move the element to the second row. You could also have added the static text
directly below the first row, but setting the row explicitly gives you more control.
• Set Column Span to 2 to have the element span both columns. You could instead set the Column
Number to 2 to move the static text under the chart.
10. Set the relative heights of the rows. To do this, select the chart and set Row Weight to 10 in the Layout
section of the Appearance tab of Properties view. You could actually do this by changing the settings on any of
the three elements, but in this case, the chart is the main element and you want other elements to adjust to it.
The tools in the context menu are specific to the selected item(s). The following tables explain the tools.
Order Tools
Align to Left Aligns the left sides to that of the primary element. Yes
Align to Center Aligns the centers to that of the primary element. Yes
Align to Right Aligns the right sides to that of the primary element. Yes
Align to Top Aligns the top sides (or the upper part) to that of the Yes
primary element.
Align to Middle Aligns the middles to that of the primary element. Yes
Align to Bottom Aligns the bottom sides (or the lower part) to that of Yes
the primary element.
Fit to Both Adjusts elements to fill width and height of container. Yes
Miscellaneous Tools
PDF 508 Tags Adds tags required for PDF 508C compliance
XLS Tags Adds tags that define how data is exported to the
Microsoft Excel format
By default, the Properties dialog displays a form with available properties grouped by category. The available
categories depend on the element type. For example, reports allow you to set a number of JDBC and timezone
properties. Each property has a widget that allows you to set the property. Deprecated properties are displayed with
strikethrough.
The Properties dialog box supports the following actions:
• Hover to view the description of a property.
• Right-click on an entry box to set the property to Null or reset it to the default value (when available).
• Click to switch to a summary table view. Using this view, you can manage multiple properties at the same
time. For example, you can select and copy multiple properties, and then paste them into another element. To
return to form view, click .
• Click to show only properties that have already been set at element level.
• Enter a string in the Search property entry bar to search for a property by name.
• Some properties include variables in the property names, shown with curly brackets {}. To use these
properties, replace the entire value, including the brackets, with the name you want to use.
You can also use styles to format some types of elements. Styles can be applied to multiple elements, but are
more restrictive. Properties must be individually applied to each element.
Create a report:
To create the report for the chart
1. Create a new, blank report using the Sample DB data adapter and the query: select * from PRODUCT.
2. Click Next.
3. Click to select all fields, then click Finish.
4. Delete all bands except for Column Header and Details.
5. In Outline view, expand the Fields node, select all fields, and drag them to the detail band.
The fields are added to the detail band and headers are automatically added to the Column Header band.
6. Drag to select the fields in the detail band, right-click, and select Align in Container > Align to Top
Margin. Then double-click the detail band to resize it to fit the fields.
6. Click the expression editor icon next to net.sf.jasperreports.style.forecolor to open the expression editor.
7. Select Use Expression and enter the following expression:
$F{COST}.compareTo(new BigDecimal(10)) > 0 ? "#FF0000" :"#000000"
8. Click Finish.
9. Click Preview to view the report.
For this example, the result is the following columns, in this order: id, name, department, address.
The {arbitrary_name} suffix can be any name you choose. The following code gives the same result at runtime:
<property name="net.sf.jasperreports.export.csv.column.names.first.column.set"
value="id,name,department"/>
<property name="net.sf.jasperreports.export.csv.column.names.address" value="address"/>
You can use multiple properties with the same prefix for dynamic properties. For example, you could generate
column names from two different parameters:
<propertyExpression name="net.sf.jasperreports.export.csv.column.names.db.columns">
<![CDATA[$P{columns1}]]>
</propertyExpression>
and
<propertyExpression name="net.sf.jasperreports.export.csv.column.names.additional.columns">
<![CDATA[$P{other_columns}]]>
</propertyExpression>
4.5.1 Line
In Jaspersoft Studio, a line is defined by a rectangle for which the line represents the diagonal. By default, the
foreground color is used as the default color and a 1-pixel-width line is used as the line style.
You can customize the look, style, and direction of the line in the element’s Properties view.
4.5.3 Images
An image is the most complex of the graphic elements. You can insert raster images (such as GIF, PNG and JPEG
images) in the report, but you can also use an image element as a canvas object to render, for example, a Swing
component, or to leverage some custom rendering code.
Dragging an image element from the Palette into the report editing area launches the Create new image
element dialog. This is the most convenient way to specify an image to use in the report. Jaspersoft Studio does
not save or store the selected image anywhere, it just uses the file location, translating the absolute path of the
selected image into an expression to locate the file when the report is executed. The expression is then set as the
value for the Image Expression property.
You can add an image by explicitly defining the full absolute path of the image file in your expression. This is an
easy way to add an image to the report, but, overall, it has a big impact on the report’s portability, since the file
may not be found on another machine (for instance, after deploying the report on a web server or running the report
on a different computer).
A text field is similar to a static text string, but the content (the text in the field) is provided using an expression
(which can be a simple static text string itself). That expression can return several kinds of value types, allowing
the user to specify a pattern to format that value. Since the text specified dynamically can have an arbitrary length,
a text field provides several options about how the text must be treated regarding alignment, position, line breaks
and so on. Optionally, the text field is able to grow vertically to fit the content when required.
By default both text elements are transparent with no border, with a black text color. The most used text properties
can be modified using the text tool bar displayed when a text element is selected. Text element properties can also
be modified using the Properties view.
Text fields support hyperlinks as well. See 4.11.4, “Creating a Hyperlink,” on page 76 for more information.
A text field that prints a constant value like the one returned by this expression can be easily replaced by a static
field; actually, the use of an expression to define the content of a text field provides a high level of control on the
generated text (even if it’s just constant text). A common case is when labels have to be internationalized and
loaded from a resource bundle. In general, an expression can contain fields, variables and parameters, so you can
print in a text field the value of a field and set the format of the value to present. For this purpose, a text field
expression does not have to return necessarily a string (that’s a text value): the text field expression class
name property specifies what type of value is returned by the expression. It can be one of the following:
java.sql.Timestam java.io.InputStrea
p m
An incorrect expression class is frequently the cause of compilation errors. If you use Groovy or JavaScript you
can choose String as expression type without causing an error when the report is compiled. The side effect is that
without specifying the right expression class, the pattern (if set) is not applied to the value.
Let’s see what properties can be set for a text field:
Blank when null If set to true, this option avoids printing the text field content if the expression result is a
null object that would be produce the text “null” when converted in a string.
Evaluation time Determines in which phase of the report creation the Text field Expression has
to be elaborated.
Evaluation group The group to which the evaluation time is referred if it is set to Group.
Text Adjust This option allows the text field to adapt vertically to the content, if the element is not
sufficient to contain all the text lines. Select the required option from the following:
• CutText: The text is cut, if it does not fit the text field element size.
• StretchHeight: The text field element is stretched in height to accommodate the
entire content.
• ScaleFont: The font size of the text is scaled down so that the entire content fits
the text field element size.
Pattern The pattern property allows you to set a mask to format a value. It is used only when the
expression class is congruent with the pattern to apply, meaning you need a numeric
value to apply a mask to format a number, or a date to use a date pattern.
4.7 Frames
A frame is an element that can contain other elements and optionally draw a border around them. Since a frame is a
container of other elements, in Outline view the frame is represented as a node containing other elements.
A frame can contain other frames, and so on recursively. To add an element to a frame, just drag the new element
from the palette inside the frame. Alternatively you can use Outline view and drag elements from a band into the
frame. The position of an element is always relative to the container position. If the container is a band, the element
position is relative to the top of the band and to the left margin. If the container (or element parent) is a frame, the
element coordinates are relative to the top left corner of the frame. Since an element dragged from a container to
another does not change its top/left properties, when moving an element from a container to another its position is
recalculated based on the new container location.
The advantages of using a frame to draw a border around a set of elements, with respect to using a simple rectangle
element, are:
• When you move a frame, all the elements contained in the frame move.
• While using a rectangle to overlap some elements, the elements inside the rectangle are not treated as if they
overlap (with respect to the frame), so you don't have problems when exporting in HTML (which does not
support overlapped elements).
• Finally, the frame automatically stretches according to its content, and the element position type property
of its elements refer to the frame itself, not to the band, making the design a bit easier to manage.
Now suppose your map is configured with an expression that only displays the map some of the time. If you size
the frame to be bigger than the map, the report inserts white space when the map is not displayed. Instead, you can
size the frame to be smaller than the map:
Now, the frame expands as necessary to include any non-null content, but no additional white space is added if the
map is not present.
Be careful when creating and modifying reports that use frames that are smaller than their contents. The user
interface does not always make it clear which elements are contained in a frame. For example, it is possible
to add a field to a frame and then resize the frame so that the frame no longer overlaps the element. To see
which elements are in a frame, select the frame and expand its node in outline view. If you have trouble mov-
ing an element inside or outside a frame, move it in outline view.
• SHIPADDRESS
• SHIPCITY
• SHIPREGION
• SHIPCOUNTRY
7. Click Finish.
Jaspersoft Studio builds the report layout with the selected fields.
Remove a Column:
1. Select the EMPLOYEEID heading and press the Delete key.
2. Click Delete Entire Column when prompted.
All elements in the same column are deleted. In this case, the header and the field are deleted. The other
elements move to the left as necessary to close the gap.
There is no option to cancel a delete. However, you can undo the action immediately.
Resize Columns:
The real advantage to spreadsheet layout is that it lets you quickly resize columns and keep the elements aligned
across bands.
1. Select the ORDERID header or text field.
2. Click the right side and move the handles to the left to reduce the size of the OrderID column. All elements in
the column are resized together.
3. Select the SHIPADDRESS header or text field. Use the handles on the right to expand the column. Again, the
columns are resized together.
Remove a Header:
1. Select the Region header and press Delete.
2. When prompted, select Delete Selected. The item is removed, but column layout is preserved.
When you delete an element from the detail band, the associated elements in other bands are no longer part
of the column layout. When you delete an element from a band other than the detail band, column layout is
not removed.
If you preview the report, it should look something like the following image.
Composite elements cannot include elements based on a dataset, such as charts or crosstabs.
For example, to create a footer that includes your company name and the page number:
a. Drag the Static Text element to the Title band in your report and type My Company. Then align the
company name to the to the left by right-clicking the Static Text element and selecting Align in
Container > Align to Left Margin.
b. Drag the Page Number element to the Title band in your report. Align the Page Number to the right by
right-clicking the Page Number element and selecting Align in Container > Align to Right Margin.
Then, with the Page Number element selected, go to the Text Field tab in the Properties view and click
to align the text right.
c. Select both elements, right-click, and choose Align Components > Align Top.
3. Select all the elements you want in your composite.
4. (Optional) To have your elements move together, right-click and select Enclose into Frame from the
context menu.
5. Make sure all elements are still selected.
You cannot delete the composite elements that are shipped with Jaspersoft Studio.
3. Select the elements you want to export in the Export Composite Elements dialog.
4. Click Finish.
5. When prompted, navigate to the location where you want to save the export file, and click OK.
The selected composite elements are saved as a .zip file in the location you chose.
5. If there are additional elements in the file, click Next and configure the next element as in the previous step.
6. When you have configured all your imported elements, click Finish.
The composite elements are placed in the palette with the settings you configured.
This section describes hyperlinks for images, text fields, and charts. Hyperlinks for HTML5 charts are defined
differently, as described in 18.9, “Creating Hyperlinks in HTML5 Charts,” on page 359.
To set anchor, bookmark, or hyperlink properties, select an image, text field, or chart element and go to the
Hyperlink tab in the Properties view.
• Bookmark Level – Bookmark level when the report is exported to PDF. If you plan to export your report as
a PDF, set a bookmark level to populate the bookmark tree, making the final document navigation much
easier. To make an anchor available as a bookmark, simply choose a bookmark level higher than 1. Defining
different levels creates nested bookmarks.
Bookmarks can also be displayed in JasperReports Server when the report is displayed in the interactive
viewer. To display bookmarks in the server, set the following property:
<property name="net.sf.jasperreports.print.create.bookmarks" value="true"/>
This property can be set on the report level or globally in the JasperReports Server
WEB-INF\classes\jasperreports.properties file.
The same table of contents is also available in the JasperPrint object, and can be explored by calling the
method:
List<PrintBookmark> getBookmarks()
4.11.2 Hyperlinks
Hyperlinks let you link a location in a report to another destination. The most important property of a hyperlink is
its type, which determines the format of the target. Jaspersoft Studio supports the following types of hyperlink: The
exact properties of a hyperlink depend on the hyperlink type. The following properties may appear for a hyperlink:
• Link Target – Specifies where to open the link target. The Link Target is similar to the target attribute of an
HTML link. The dropdown box shows the following options: Self, Blank, Top, Parent. You can also possible
specify a target name, which actually makes sense only when the hyperlink is used in a web environment.
• Link Type – The following link types are supported in Jaspersoft Studio: Reference, Local Anchor, Local
Page, Remote Anchor, Remote Page, and ReportExecution. You can also defined your own custom hyperlink
types.
• Target Expressions – Expressions that determine the location of the link target. May include:
• Hyperlink Anchor Expression – Anchor in document to use as hyperlink target.
• Hyperlink Page Expression – Page in document to use as hyperlink target.
• Hyperlink Reference Expression – Location of remote document. For link of type Reference, use a
URL; for a link of type Remote Anchor or Remote Page, use a file reference.
• Hyperlink When Expression – Expression that determines when the hyperlink is implemented. A hyperlink
is only available if the Hyperlink When expression returns the Boolean value True (default).
• Tooltip Expression – String to use as a tooltip when a user hovers the cursor over the hyperlink.
• Parameters – Parameters that specify information about the target; only available for ReportExecution
hyperlinks and custom hyperlink types.
ReportExecution is implemented as a custom hyperlink type in JasperReports Library.
ReportExecution hyperlinks are an example of custom hyperlink extensions in JasperReports Library. More
generally, these parameters can be used by URL Handlers, especially JasperReports Library extensions, to
manipulate and generate hyperlinks.
Figure 4-22 Dragging a report from the server into the Report Design
The auto-configured hyperlink automatically sets the type to ReportExecution and configures the _report
parameter. Moreover, if the JasperReports Server Report has input controls, they are added to the list of parameters,
ready to be populated with a proper value expression, as shown below.
Reference The Reference link indicates an external source that is identified by a normal URL. This is
ideal to point, for example, to a servlet to manage a record drill-down tool. The only
expression required is the hyperlink reference expression.
LocalAnchor To point to a local anchor means to create a link between two locations into the same
document. It can be used, for example, to link the titles of a summary to the chapters to
which they refer.
To define the local anchor, specify a hyperlink anchor expression that produces a valid
anchor name.
LocalPage If instead of pointing to an anchor you want to point to a specific current report page, you
need to create a LocalPage link. In this case, it is necessary to specify the page number
you are pointing to by means of a hyperlink page expression (the expression has to return
an Integer object).
RemoteAnchor If you want to point to a particular anchor that resides in an external document, you use the
RemoteAnchor link. In this case, the URL of the external file referenced must be specified
in the Hyperlink Reference Expression field, and the name of the anchor must be specified
in the Hyperlink Anchor Expression field.
RemotePage This link allows you to point to a particular page of an external document. Similarly, in this
case the URL of the external file pointed to must be specified in the Hyperlink Reference
Expression field, and the page number must be specified by means of the hyperlink page
expression. Some export formats have no support for hypertext links.
ReportExecution This type of hyperlink is used to implement JasperReports Server’s drill-down feature.
To create a hyperlink:
1. Click the Hyperlink tab in the Properties view.
2. In the Link Target drop-down, choose one of the following target types:
• Self: This is the default setting. It opens the link in the current window.
• Blank: Opens the target in a new window. Used for output formats such as HTML and PDF.
• Top: Opens the target in the current window but outside eventually frames. Used for output formats such
as HTML and PDF.
• Parent: Opens the target in the parent window (if available). Used for output formats such as HTML and
PDF.
3. In the Link Type drop-down, choose whether the link type is None, Reference, LocalAnchor, LocalPage,
RemoteAnchor, RemotePage, or ReportExecution.
4. Click the button next to Hyperlink Tool Expression to create a tooltip for your hyperlink.
5. Save your report.
Please note that this component is only supported by the Jaspersoft Community
(community.jaspersoft.com). TIBCO Jaspersoft Technical Support and Engineering do not support it.
D3-enabled report
The custom visualization component is a powerful and flexible feature, suitable for advanced users of
JasperReports Library. Using the component requires advanced coding skills in the following technologies:
• JavaScript
• CSS
• HTML/DHTML
• Optionally, any third-party library you want to expose in Jaspersoft Studio and JasperReports Server.
Before creating reports that use your third-party library, you must configure various applications to work together;
you must:
1. Install Chrome or Chromium, which renders your JavaScript module's visual component.
2. Configure Jaspersoft Studio and JasperReports Server to use Chrome/Chromium.
3. Create a JavaScript module that renders an SVG. This main module, as well as any JavaScript it relies on, are
optimized and combined into a single JavaScript file (using a RequireJS build file (build.js). Jaspersoft Studio
simplifies the optimization process to generate the JavaScript implementation of the component. Place your
JavaScript files somewhere that Jaspersoft Studio can find it, such as attaching it to the report unit or placing it
on the classpath.
Next, create and deploy reports that rely on your custom visualization component to render SVG images. Drag the
Custom Visualization component from the Elements palette into the Design tab, and create a report-level property
of type com.jaspersoft.jasperreports.components.customvisualization.require.js; it must
specify the main JavaScript file for your custom visualization. The custom visualization component appears as a
rectangular area of your report. A single custom visualization component can be used by any number of reports that
require the same JavaScript functionality. When exported to HTML format, these reports can be interactive
(assuming that your module attaches events to the DOM).
You can also create a custom component descriptor in JSON, which lets you add the following to your component:
• A component UI – You can specify the property names and types and the data items used by the component.
• A thumbnail image – Used when the component is presented in the component choose, which appears when a
component is dragged into the design view.
• Location of implementation files – You can specify the location of the JavaScript file and CSS file which
implement the component.
This component can help you leverage any number of JavaScript libraries, such as:
• D3.js
• Raphäel
• Highcharts
• JQuery
For more in-depth information, please see the articles on our Community wiki that describe the custom
visualization component.
Select the Advanced tab to enter advanced properties for the field.
where <field name> must be replaced with the name of the field. When using a field expression (for example,
calling a method on it), keep in mind that it can have a value of null, so you should check for that condition. An
example of a Java expression that checks for a null value is:
This method is generally valid for all the objects, not just fields. Using Groovy or JavaScript this is rarely a
problem, since those languages handle a null value exception in a more transparent way, usually returning an empty
string.
In some cases a field can be a complex object, like a JavaBean, not just a simple value like a String or an Integer.
A trick to convert a generic object to a String is to concatenate it to an empty string this way:
$F{myfield}+ “”
All Java objects can be converted to a string; the result of this expression depends on the individual object
implementation (specifically, by the implementation of the toString() method). If the object is null, the result
returns the literal text string “null” as a value.
Jaspersoft Studio doesn't require a query to generate a report. It can obtain data from a data source that is not
defined by a query execution. JasperReports supports multiple query languages including:
• JSON
• MongoDBQuery
• PLSQL
• SQL
• XLS
• XPath
If the selected data source is a JDBC connection, Jaspersoft Studio tests the access connection to the data source as
you define the query. This allows Jaspersoft Studio to identify the fields using the query metadata in the result set.
The design tool lists the discovered fields in the bottom portion of the window. For each field, Jaspersoft Studio
determines the name and Java type specified by the JDBC driver.
If your query accesses tables containing large amounts of data, scanning the data source for field names could take
a while. In this case you might consider disabling the Automatically Retrieve Fields option to quickly finish
your query definition. When you've completed the query, click the Read Fields button to start the fields discovery
scan.
All fields used in a query must have a unique name. Use alias field names in the query for fields having the
same name.
The field name scan may return a large number of field names if you are working with complex tables. To reduce
unnecessary complexity, we suggest that you review the list of discovered names and remove fields you're not
using in your report. When you click OK all the fields in the list are included in the report design. Although you
can remove them later in the outline view, it’s a good idea at this point in the design process to remove any field
names that you won’t be using.
Jaspersoft Studio creates new fields corresponding to the selected attributes and adhesion to the list. The
description, in this case, stores the method that the data source must invoke to retrieve the value for the specified
field.
Jaspersoft Studio parses a description such as address.state (with a period between the two attributes) as an
attribute path. This attribute path is passed to the function getAddress() to locate the target attribute, and then to
getState() to query the status of the attribute. Paths may be arbitrary and long, and Jaspersoft Studio can
recursively parse attribute trees within complex JavaBeans and in order to register very specific fields.
We have just discussed the two tools used most frequently to register fields, but we’re not done yet. There are
many other tools you can use to discover and register fields, for instance, the HQL and XML node mapping tools.
Setting the property globally inserts tags when you export a report to PDF directly from Jaspersoft Studio. If
you are publishing your reports to another environment, such as JasperReports Server, you must enable this
property in the jasperreports.properties file in your environment. See the JasperReports Server Administrator
Guide for more information about enabling this property for JasperReports Server.
6. Select Is Tagged.
7. Enter a language code in the Tag Language field.
5.5.2 Configuring a Report's Metadata for Use With the JSON Data Exporter
JasperReports Server's REST API includes a JSON (JavaScript Object Notation) data exporter that enables you to
feed pure data into applications you integrate with the server. During report generation, this exporter skips all
layout-related steps and returns a dataset. The structure of this data is determined by metadata you define in your
report. You can also define expressions to determine how data from a specific filed is exported.
Note: The ability to define metadata and export data in JSON format is sometimes referred to as the JasperReports
Data API.
You can define a structure by separating the names of the levels you want to create with periods (.). For example,
consider a report with three fields configured with these JSON properties:
$F{salesyear} store.sale.year
$F{cust.name} store.cust.name
When exported to JSON, the data is structured with three distinct paths:
store
sale
amount
year
cust
name
[
{store:
[
{
sale:[{amount:"19000", year:2014}],
cust:[{name:"Acme"}],
}
]
}
]
Note that when you preview your report as JSON, the data is not formatted to be human readable, as above. You
may want to use one of the many JSON formatting tools to review the output of your JSON tagged report, you can
copy the JSON output from the Preview tab.
It's important to define paths that create a structure that the application receiving the data can interpret.
8. Select each field you want to export to JSON and define its metadata.
9. Click File > Save.
10. Click Preview.
11. If the JSON Metadata preview isn't selected, click the arrow next to the current preview format, and select
JSON Metadata.
12. Review the structure of the data to ensure your application can interpret it.
13. If the data isn't structured correctly, click Design and edit each field's JSON export properties.
14. When you're satisfied with the data returned by Jaspersoft Studio, you can publish your report to JasperReports
Server and begin testing your own application's ability to use the data passed by the server.
6.1.1.2 Managing Parameters Using the Parameters tab in the Dataset and Query Dialog
• To toggle show/hide system parameters, click .
• To toggle show/hide parameter properties, click .
• To add a parameter, click Add on the Parameters tab.
• To delete a parameter, select it in the Parameters tab and click Delete. The Delete button is grayed out for
system parameters, which cannot be deleted or edited.
• To add a parameter property, make sure parameter properties are displayed, select the Parameter, and click
Add Property.
• To view or edit parameter properties, double-click the parameter, or select it in the Parameters tab and click
Edit (grayed out for system parameters). A Parameter dialog opens. To view or edit advanced properties, click
… next to Properties in the Parameter dialog.
Also see 11.1, “Using the Dataset and Query Dialog,” on page 197.
you can use properties to include the description of the parameter in different languages or to add instructions about
the format of the input prompt.
Selecting Properties, and clicking … brings up the Properties dialog box. For example, if you have a web
services type data adapter, you see the following properties.
Some built-in parameters are specific to a query language. For example if you're using the Hibernate query
language, the reports automatically includes the HIBERNATE_SESSION parameter that holds the Hibernate session
for the HQL query.
The built-in parameters are:
Parameter Description
REPORT_CONTEXT
JASPER_REPORT This parameter gives access to the current JasperReport template object
that is being filled.
REPORT_CONNECTION This is the JDBC connection passed to the report when the report is created
through an SQL query.
REPORT_MAX_COUNT This limits the number of records filling a report. If no value is provided, no limit
is set.
REPORT_DATA_SOURCE This is the data source used by the report when it's not using a JDBC
connection.
REPORT_SCRIPTLET This represents the scriptlet instance used during report creation. If no
scriptlet is specified, this parameter uses an instance of
net.sf.jasperreports.engine.JRDefaultScriptlet.
REPORT_LOCALE This specifies the locale used to fill the report. If no locale is provided, the
system default is used.
REPORT_TIME_ZONE This is used to set the time zone used to fill the report. If no value is provided,
the system default is used.
REPORT_CLASS_LOADER This parameter can be used to set the class loader to use when filling the
report.
REPORT_URL_HANDLER_ Class used to create URL handlers. If specified, it replaces the default.
FACTORY
Parameter Description
SORT_FIELDS This is a in-memory field-based data source sorting. The sorting is activated
by the presence of one or more <sortField> elements in the report
template.
REPORT_VIRTUALIZER This defines the class for the report filler that implements the
JRVirtualizer interface for filling the report.
IS_IGNORE_PAGINATION You can switch the pagination system on and off with this parameter (it must
be a Boolean object). By default, pagination is used except when exporting to
HTML and Excel formats.
In this example the my_order_id parameter contains the ID of the order to be read. This parameter can be passed
to the report from the application running it to select only a specific order. Please note that the parameter here is a
valid SQL parameter, meaning that the query can be executed using a prepared statement like:
SELECT * FROM ORDERS WHERE ORDER_ID = ?
and the value of the parameter my_order_id is then passed to the statement.
In this query:
SELECT * FROM ORDERS ORDER BY $P!{my_order_field}
my_order_field cannot be treated as an SQL parameter. JasperReports considers this parameter a placeholder
(note the special syntax $P!{}) is replaced with the text value of the parameter.
Using the same logic, a query can be fully passed using a parameter. The query string would look like:
$P!{my_query}
A query can contain any number of parameters. When passing a value using the $P!{} syntax, the value of the
parameter is taken as is, the user is responsible of the correctness of the passed value (SQL escaping is not
performed by JasperReports in this case). When using a parameter in a query, a default value must be set for the
parameter to allow Jaspersoft Studio to execute the query to retrieve the available fields.
The set here is defined by the countries USA, Italy and Germany. Assuming we are passing the set of countries in a
list (or better a java.util.Collection) or in an array, the syntax to make the previous query dynamic in
reference to the set of countries is:
SELECT * FROM ORDERS WHERE $X{IN, SHIPCOUNTRY, myCountries}
where myCountries is the name of the parameter that contains the set of country names. The $X{} clause
recognizes three parameters:
A relative date expression is always calculated in the time zone of the logged-in user. However, the
start day of the week can be configured independent of locale.
Relative dates don't currently support keywords like "Week-To-Date" (from the start of the current week to the
end of the current day). However, you can set a relative date period in a query in JRXML using BETWEEN,
which has the syntax:
$X{BETWEEN, column, startParam, endParam}
For example, to create a week-to-date query, set startParam to WEEK and endParam to DAY. You can do
this for other time ranges, such as Year-To-Day, Year-To-Week, and so forth.
To use date ranges, create a parameter with type date range and use it as the third argument in the $X{} function.
To set the default value expression of a date range parameter, use the DateRangeBuilder() class to cast the
expression to the correct type:
• new net.sf.jasperreports.types.date.DateRangeBuilder("DAY-1").toDateRange() – casts a keyword
text string to a DateRange.
• new net.sf.jasperreports.types.date.DateRangeBuilder("WEEK").set(Timestamp.class).toDateRange
() – casts a keyword text string to a TimestampRange.
• new net.sf.jasperreports.types.date.DateRangeBuilder("2012-08-01").toDateRange()– casts a date in
YYYY-MM-DD format to a DateRange.
• new net.sf.jasperreports.types.date.DateRangeBuilder("2012-08-01 12:34:56").toDateRange()–
casts a date in YYYY-MM-DD HH:mm:ss format to a TimestampRange.
The following JRXML example shows data from the previous day:
This JRXML example shows results prior to the end of last month:
Problem Solution
Set up a relative date parameter called StartDate that takes the value: QUARTER. QUARTER evaluates to the first
day (the first instant, really) of this quarter.
Find all purchases made SQL: select * from orders where $X{LESS, order_date,
previous to this quarter StartDate}
Find all purchases made in this select * from orders where $X{EQUAL, order_date,
quarter StartDate}
Use BETWEEN to set up input controls that allow the user to specify a range (other than a day) using either a relative
date expression or actual dates. To do this:
• Define two date range parameters, for example, StartDate and EndDate.
• Optionally, set default values for one or both parameters using defaultValueExpression.
• Use a $X{} expression with a BETWEEN function in your query.
• Create a date type input control for each parameter, for example, StartDate and EndDate.
The following JRXML example uses the BETWEEN keyword in the $X() function to find all data from the previous
20 years:
You can use the getStart() and getEnd() methods to get the precise beginning and end of a relative date. Both
of these methods return a date instead of a date range. The following example shows how to get the precise start
date as a default value expression.
...
HashMap hm = new HashMap();
...
JasperPrint print = JasperFillManager.fillReport(
fileName,
hm,
new JREmptyDataSource());
...
fillReport is a key method that allows you to create a report instance by specifying the file name as a parameter,
a parameter map, and a data source. (This example uses a dummy data source created with the class
JREmptyDataSource and an empty parameter map created using a java.util.HashMap object.)
Let’s see how to pass a simple parameter to a reporting order to specify the title of a report.
The first step is to create a parameter in the report to host the title (that is a String). We can name this parameter
REPORT_TITLE and the class is java.lang.String (Figure 6-6).
All the other properties can be left as they are. Drag the parameter into the Title band to create a text field to
display the REPORT_TITLE parameter.
To set the value of the REPORT_TITLE parameter in our application, modify the code of the previous source code
example by adding:
...
HashMap hm = new HashMap();
hm.put(“REPORT_TITLE”,”This is the title of the report”);
...
JasperPrint print = JasperFillManager.fillReport(
fileName,
hm,
new JREmptyDataSource());
...
We have included a value for the REPORT_TITLE parameter in the parameter map. You don't need to pass values
for all the parameters. If you don’t provide a value for a certain parameter, JasperReports assigns the value of
Default Value Expression to the parameter with the empty expression evaluated as null.
When printing the report, Jaspersoft Studio includes the String This is the title of the report in the
Title band. In this case we just used a simple String. But you can pass much more complex objects as parameters,
such as an image (java.awt.Image) or a data source instance configured to provide a specified subreport with
data. The most important thing to remember is that the object passed in the map as the value for a certain parameter
must have the same type (or at least be a super class) of the type of the parameter in the report. Otherwise,
Jaspersoft Studio fails to generate the report and returns a ClassCastException error.
Be sure the Input Parameter window is open. If not, click the gray right-arrow to the left of the Preview
screen.
2. Add a value for the MESSAGE parameter. For this example, type Parameter Example.
3. Press the Play button. The message is printed in the title band.
Jaspersoft Studio provides input dialogs for parameters of type String, Date, Time, Number, and Collection.
2. Select the parameter set you want to add to your report and click Finish.
The parameters in the set are added to your report.
4. To create an individual parameter inside your set, click Add in the Parameter Set dialog.
The Parameter dialog is displayed.
5. Add and configure the parameter. The following settings are available:
• Name – Name of the parameter.
• Class – Class type of the parameter.
• Description – A string describing the parameter. This is shown as the parameter tooltip in the Input
Parameters pane in preview.
• Nested Type Name
• Is for Prompting – Enable this to have Jaspersoft Studio prompt for the parameter when you preview
the report. If you have this selected and are publishing the report to the server, you will need to create
input controls on the server. May also be passed to an external application.
• Value – Default value for the parameter. This value is used if no value is provided for the parameter from
the application that executes the report. The type of value must match the type declared in the Class field.
For example, if you are creating a Country parameter, you might use the value $F{SHIPCOUNTRY} for
your parameter.
6. Click OK to create the parameter and return to the Parameter Set dialog.
7. When you have created all the parameters you want, click OK to return to the Preferences dialog.
8. Click OK to return to design view and create your parameter set.
To use your parameter set in a report, select Create Parameter Set from the Parameters context menu in outline
view.
• Type: Necessary because a variable is an object that is probably used in other expressions, so its type must be
known to be manipulated correctly.
• Expression: The function used to define the variable value, it can be composed of more fields and variables,
which could be logic operators, math operators and so on. Jaspersoft Studio provides an expression editor. To
open it, click the button to the right of the expression text field. The expression is evaluated on each iteration
(every time a record is read from the data source). If no calculation function is defined, the result of the
expression is assigned to the variable. So it's important that the result has a type compatible with the one in the
variable.
• Initial Value: The value assumed from the variable at the beginning, before the first computation of its
expression. The initial value is an expression itself, so it can be defined through the expression editor.
• It's not mandatory, but it's good practice to define an initial value. For example, if you have a variable called
variable1 with the expression new Integer(5), at every iteration, the variable is assigned the integer
value 5. In this context the initial value isn't important. But if you change the expression to $V
{variable1}+5, at every iteration the variable is incremented by 5. In this case, an initial value is necessary
because if the variable1 is undefined at the first iteration, all future evaluations will break.
information), instead the fields are always evaluated at time -now. This type is useful when report elements
have expressions that combine values evaluated at different times (for example, percentage out of a total).
• Now: The value of the expression is evaluated after the read of every record, so at every iteration, this is the
default behavior.
PAGE_NUMBER Contains the current number of pages in the report at report time.
PAGE_COUNT Contains the current number of records processed in the current page.
COLUMN_COUNT Contains the current number of records processed during the current column
creation.
MASTER_CURRENT_PAGE It is used in subreports or report parts to display the current page number.
MASTER_TOTAL_PAGES It is used in subreports or report parts to display the total number of pages.
java.lang.Boolean Defines an Object that represents a Boolean value such as true and
false
java.lang.Byte Defines an Object that represents a byte
java.lang.Short Defines an Object that represents an short integer
java.lang.Integer Defines an Object that represents integer numbers
java.lang.Long Defines an Object that represents long integer numbers
java.lang.Float Defines an Object that represents floating point numbers
java.lang.Double Defines an Object that represents real numbers
java.lang.String Defines an Object that represents a text
java.util.Date Defines an Object that represents a date or a timestamp
java.lang.Object A generic java Object
If an expression is used to determine the value of a condition that determines, for instance, whether an element
should be printed, the return type is java.lang.Boolean. To create it, you need an expression that returns an
instance of a Boolean object. Similarly, if an expression shows a number in a text field, the return type is
java.lang.Integer or java.lang.Double.
Neither JavaScript nor Groovy is particularly formal about types, since they are not typed languages; the language
itself treats a value in the best way by trying to guess the value type or by performing implicit casts (conversion of
the type).
+ Sum (it can be used to sum two numbers or to concatenate two strings) A + B
- Subtraction A - B
/ Division A / B
|| Boolean operator OR A || B
== Equals A == B
!= Not equals A != B
Regarding the Equals operator: in Java, the == operator can only be used to compare two primitive values.
With objects, you need to use the special method “equals”; for example, you cannot write an expression like
"test" == "test", you need to write "test".equals("test").
Regarding the Equals operator: in Java, the != operator can only be used to compare two primitive values.
Within an expression, you can use the syntax summarized in Table 8-2, “Syntax for referring to report objects,”
on page 119 to refer to the parameters, variables, and fields defined in the report.
Syntax Description
$P!{name_ Special syntax used in the report SQL query to indicate that the parameter does not
parameter} have to be dealt as a value to transfer to a prepared statement, but that it represents a
little piece of the query.
$X{functionName, Syntax for complex queries, such as comparing a column value to a parameter value.
col_name, param1, Based on the function in the first argument, JasperReports constructs a SQL clause.
[param2]} The following functions are available:
• Functions expecting three arguments for $X{} – EQUAL, NOTEQUAL, LESS, LESS]
(less than or equal to), GREATER, [GREATER (greater than or equal to), IN, NOTIN.
For example:
$X{EQUAL, order_date, date_parameter}
• Functions expecting four arguments for $X{} –
BETWEEN (excludes both endpoints)
BETWEEN] (includes right endpoint)
[BETWEEN (includes left endpoint)
[BETWEEN] (includes both endpoints)
For example:
$X{BETWEEN, order_date, start_date_param, end_date_param}
In summary, fields, variables and parameters represent objects; specify their type when you declare them within a
report.
Although expressions can be complicated, usually it is a simple operation that returns a value. There is a simple if-
else expression that is very useful in many situations. An expression is just an arbitrary operation that any stage
must represent a value. In Java, these operators can be applied only to primitive values, except for the sum operator
(+). The sum operator can be applied to a String expression with the special meaning of concatenate. For example:
$F{city} + “, ” + $F{state}
Any object in an expression can include methods. A method can accept zero or more arguments, and it can return
or not a value. In an expression you can use only methods that return a value; otherwise, you would have nothing
to return from your expression. The syntax of a method call is:
Object.method(argument1, argument2, <etc.>)
Some examples:
Expression Result
“test”.length() 4
“test”.substring(0, 3) “tes”
“test”.startsWith(“A”) false
The methods of each object are usually explained in the JasperReports Library Javadocs, which are available at
http://jasperreports.sourceforge.net/api/.
You can use parentheses to isolate expressions and make the overall expression more readable.
The syntax is (<condition>) ? <value on true> : <value on false>. It is extremely useful, and can
be recursive, meaning that the value on true and false can be represented by another expression which can be a
new condition:
(($F{name}.length() > 50) ?
(($F{name}.startsWith(“A”)) ? “AAAA” : “BBB”)
:
$F{name})
This expression returns the String AAAA when the value of the field name is longer than 50 characters and starts
with A, returns BBB if it is longer than 50 characters but does not start with A, and, finally, returns the original
field value if neither of these conditions is true.
Despite the possible complexity of an expression, it can be insufficient to define a needed value. For example, if
you want to print a number in Roman numerals or return the name of the weekday of a date, it is possible to
transfer the elaborations to an external Java class method, which must be declared as static, as shown in the
following example:
MyFormatter.toRomanNumber( $F{MyInteger}.intValue() )
The function operand toRomanNumber is a static method of the MyFormatter class, which takes an int as
argument (the conversion from Integer to int is done by means of the intValue() method; it is required only
when using Java as language) and gives back the Roman version of a number in a lace.
This technique can be used for many purposes; for example, to read the text from a CLOB field or to add a value
into a HashMap (a Java object that represents a set of key/value pairs).
If you use this character in a static text element, “\u20ac” will appear. The value of a static field is not
interpreted as a Java expression.
The first thing to note is that each of these expressions represents a Java Object, meaning that the result of each
expression is a non-primitive value. The difference between an object and a primitive value makes sense only in
Java, but it is very important: a primitive value is a pure value like the number 5 or the Boolean value true.
Operations between primitive values have as a result a new primitive value, so the expression:
5+5
results in the primitive value 10. Objects are complex types that can have methods, can be null, and must be
“instanced” with the keyword “new” most of the time. In the second example above, for instance (new Boolean
(true)), we must wrap the primitive value true in an object that represents it.
By contrast, in a scripting language such as Groovy and JavaScript, primitive values are automatically wrapped into
objects, so the distinction between primitive values and objects wanes. When using Java, the result of our
expression must be an object, which is why the expression 5+3 is not legal as-is but must be fixed with something
like this:
new Integer( 5 + 3 )
The fix creates a new object of type Integer representing the primitive value 8.
So, if you use Java as the default language for your expressions, remember that expressions like the following are
not valid:
• 3 + 2 * 5
• true
• (($P{MyParam} == 1) ? "Yes" : "No")
These expressions don’t make the correct use of objects. In particular, the first and the second expressions are not
valid because they are of primitive types (integer in the first case and boolean in the second case) which do not
produce an object as a result. The third expression is not valid because it assumes that the MyParam parameter is a
primitive type and that it can be compared through the == operator with an int, but it cannot. In fact, we said that
parameters, variables, and fields are always objects and primitive values cannot be compared or used directly in a
mathematical expression with an object.
JREmptyDataSource is a class of JasperReports that creates an empty record set (meaning with the all fields set
to null). You can see how you can instance this class (a pure Java class) in Groovy without any problem. At the
same time, Groovy allows you to use a simple expression like this one:
5+5
The language automatically encapsulates the primitive value 10 (the result of that expression) in a proper object.
Actually, you can do more: you can treat this value as an object of type String and create an expression such as:
5 + 5+ ”my value”
Whether or not such an expression resolves to a rational value, it is still a legal expression and the result is an
object of type String with the value:
10 my value
Hiding the difference between objects and primitive values, Groovy allows the comparison of different types of
objects and primitive values, such as the legal expression:
$F{Name} == “John”
$F{Age} > 18 Returns true if the Age object interpreted as a number is greater than
18.
“340” < 100 Always returns false.
“340”.substring(0,2) < 100 Always returns true (since the substring method call produces the
string “34”, which is less than 100).
Groovy provides a way to greatly simplify expressions and never complains about null objects that can crash a Java
expression throwing a NullPointerException. It really does open the doors of JasperReports to people who
don’t know Java.
This is a valid JavaScript expression creating a Java object (in this case a java.lang.String) and using its
methods.
JavaScript is the best choice for users who have no knowledge of other languages. The other significant advantage
of JavaScript is that it is not interpreted at run time, but instead generates pure Java byte-code. As a result, it offers
almost the same performance as Java itself.
Note: Rhino JavaScript engine has been removed from JasperReports Server. With the removal of Rhino JS,
reports created using JavaScript will not function unless you add Rhino JS back to your deployment. This can be
done by stopping the web server, downloading version 1.7.14 which at the time of writing is not known to have
any CVEs. This file can be replaced into the WEB-INF/lib folder, and reports that rely on JavaScript will again be
functional.
• Add from URL – Specify a URL location for a zip file of the fonts you want to add as extensions. To add all
the Noto fonts from Google, click and select the Noto URL.
• Add from Path – Specify a folder containing the fonts you want to add as extensions.
• Duplicate – Create a copy of the selected font extension(s) and/or font set(s). Each copy has a unique name,
which can be edited.
• Delete – Delete the selected font extension(s) and/or font set(s). This does not remove the original font files
from your system.
• Up – Move the selected font extension and/or font set up in the list of fonts.
• Down – Move the selected font extension and/or font set down in the list of fonts.
• Create Set – Combine the selected font extensions into a font set.
• Add to Set – Add the selected font extension(s) to an existing font set. Clicking this displays a dialog where
you can select the font set you want to add the extensions to.
• Edit – Edit the selected font extension or set. For a font extension, displays The Font Family Dialog. For a
font set, displays the Font Set dialog.
• Export – Export the selected font extension or set.
• Embed this font in PDF document (deprecated) – Flag that specifies whether to embed the font in a
generated PDF or not. Embedding fonts is recommended to ensure consistency across platforms.
If a mapping is present, then web fonts are not used. Do not define a font mapping unless you want to
override the web font functionality.
• Mapped Font Name – Click on a value to edit the name of the mapped font.
• Custom Locales – Enter the ISO language code for a language not on the list of predefined locales. You can
enter the language (required), an optional country, and an optional variant, as supported by ISO 639-1.
3. Click ... and browse to the folder that contains the fonts you want, then click Finish.
Jaspersoft Studio loads all the fonts at that location, extracts the font family name embedded in the font files,
and displays all the extracted fonts in the Preferences dialog.
Once you have create a font extension, you can edit it by double-clicking its name in the font list or by
selecting it and clicking Edit. See 9.1.2, “The Font Family Dialog,” on page 127 for more information.
3. Enter a name for your font set and click OK. This example uses SampleFontSet.
The new font set is displayed in the font list.
Next, configure the fonts in the font set so that Lobster is only used for Cyrillic characters, even though it supports
Latin characters.
3. To prevent Lobster from being used by Latin characters, click Add next to the Exclude Scripts list.
The Scripts name dialog is displayed.
4. Select Latin in the Scripts Name dialog and click OK.
Latin is added to the list of excluded scripts.
5. Click OK to close the Scripts Name dialog; click OK again to close the Font Set Family dialog and click OK a
third time to close the Preference dialog.
6. Click Finish.
e. Click Finish.
The default font used for a new static text element is SansSerif. This font does support for extended characters,
but because it's a Java logical font that is translated to a physical font by the JVM, you won't know what font
will be selected when the report is run.
6. Select SampleFontSet from the Font menu and 24 from the size menu next to it. Then resize the static text
element so it is large enough to display the text.
7. Save and preview the report. The license for these fonts let you preview the report as a PDF.
2. In the Publish To JasperReports Server dialog, select the JasperReports Server instance you want and choose a
location for the report. This example uses Public > Samples > Reports.
3. Enter a name for the report on JasperReports Server. This example uses SampleFontSetReport.
4. Click Next.
5. Verify that OneEmptyRecord appears as a resource to publish on the next page, then click Next.
6. Verify that Don't use any Data Source is selected on the Configure the Data Source page. Making this
selection ensures that the uploaded adapter will be used for the report.
7. Click Finish. If the publishing process succeeds, a success dialog is displayed.
8. Click OK to exit the success dialog.
When working with fonts, look carefully at your uploaded reports. For some fonts or character sets, you will
not see misformatted text; instead, the text will not be displayed at all.
When verifying font extensions and sets, it is best to run the report in JasperReports Server from a web
browser. Running the report from Repository Explorer in Jaspersoft Studio may not show the fonts correctly.
4. Select the data adapter type you want and click Next.
5. Enter a name for your adapter. This name is used when you select an adapter for a report.
6. Enter the properties needed by the adapter type you selected. For example, for a database JDBC connection
you need to select a JDBC driver and set the URL and database username and password. For a CSV file, you
need to enter a filename, column names, and the column separator.
7. (Optional) If you want to test the connection, click the Test button if available.
8. Click Finish to create the adapter.
The adapter is saved as an XML file in the project location you selected.
2. Select a location in the same project as the report that will be using this adapter, enter a name for the file, and
click OK.
A simple XML file is created in the location you chose. The data adapter must be in the same project as your
report. To use the same adapter in more than one project, see 10.1.3, “Copying a Data Adapter,” on
page 146.
Data adapters are hierarchical. That is, if no adapter is directly defined for a subdataset, it looks for the adapter of
its parent dataset, then its parent's parent, and so forth.
JasperReports Library. Therefore, when you publish or deploy a report, you need to specify the data source you
want to use in the deployed report. You can do this in the following ways:
• When you publish a report to JasperReports Server, you can select a JasperReports Server data source to use.
See 12.3, “Publishing a Report to JasperReports Server,” on page 217 for more information. If you choose
this method to select a data source, any subdatasets in the report must use the same data source.
• You can choose to set the default data adapter explicitly for the report and/or any subdatasets. You can set this
property separately for any dataset in the report. If this property is present, you cannot choose a different
adapter to preview the report.
4. Choose the format to use for specifying the data adapter location:
• Workspace resource – A file in your workspace, for example, value="test/sample-
adapter.jrdax"/>. This should be a file in the same project as your report. If you want to use a global
adapter, you need to export it to a file first. See 10.1.2, “Importing and Exporting Data Adapters,” on
page 145 for more information.
• Absolute Path in the file system – A file path, for example,
value="file:///C:/Adapters/sample-adapter.jrdax"
• URL – A remote URL that hosts the data adapter file, for example,
value="http://myserver:8080/sample-adapter.jrdax"
• Custom value – A free-form string that identifies the location of the data adapter to use. You could use
this if you wanted to enter a string in the repo: syntax, for example,
value="repo:/reports/interactive/CustomersDataAdapter" See 12.9, “Understanding the
repo: Syntax,” on page 245 for more information.
5. If you selected Workspace resource or Absolute Path, click Browse to locate the file in the workspace
or in your file system. Otherwise, enter the URL or free-form string.
6. Click Finish.
The default data adapter is set for the dataset. It is represented in the JRXML file using the
net.sf.jasperreports.data.adapter property.
3. Name the connection (use a significant name like Mysql – Test). This is the name that will appear on the
list of available connections when you create a report.
4. In the JDBC Driver field, specify the JDBC driver to use for your database connection. The drop-down
displays the names of the most common JDBC drivers.
If a driver is displayed in red, the JDBC driver class for that driver is not present in the class path and you
must obtain and install the driver before using it. See 10.3.3, “Using a Database JDBC Connection,” on
page 154.
JasperReports Server includes the TIBCO JDBC drivers for the following commercial databases: Oracle, MS
SQLServer and DB2. In some cases, these drivers provide functionality not provided by the vendors' driver.
However, there may be some differences in queries between the two drivers. You can use the TIBCO drivers,
or you can choose to install and use the driver supplied by the database vendor.
If you upload your reports to JasperReports Server, make sure to use the same driver in both JasperReports
Server and Jaspersoft Studio.
10.3.2.1 ClassNotFoundError
The ClassNotFoundError exception occurs whenever a data adapter fails to load a class it requires. In the
context of JDBC connections, the most likely cause is that the required JDBC driver is not present in the classpath.
In general, a data adapter has two classpaths it uses to find libraries. First the adapter looks at any paths that were
specified inside the data adapter when it was created. If it cannot load the libraries or classes it needs using its
internal paths, the data adapter uses the Jaspersoft Studio classpath to look for them.
The Jaspersoft Studio classpath is defined in your Eclipse project. As Jaspersoft Studio uses its own class loader,
it's enough to add resources such as jar files and directories containing classes to the Jaspersoft Studio classpath.
For example, suppose you want to create a connection to an Oracle database. Jaspersoft Studio does not ship the
vendor's driver for this database. If you choose the oracle.jdbc.driver.OracleDriver driver, when you test
the connection, you'll see the ClassNotFoundException, as shown in Figure 10-9. You need to add the JDBC
driver for Oracle, ojdbc14.jar, to the classpath.
BIGINT Long
The table doesn't include special types like BLOB, CLOB, ARRAY, STRUCT, and REF, because these types
cannot be managed automatically by JasperReports. However, you can use them by declaring them generically as
Object and managing them by writing supporting static methods. The BINARY, VARBINARY, and
LONGBINARY types should be dealt with in a similar way. With many databases, BLOB and CLOB can be
declared as java.io.InputStream.
Whether an SQL type is converted to a Java object depends on the JDBC driver used.
For the automatic registration of SQL query fields, Jaspersoft Studio relies on the type proposed for each field by
the driver itself.
Clicking the Data Preview tab shows a subset of your filtered data. The filter expression must return a Boolean
object: true if a particular record can be kept, false otherwise.
If no fields can be selected with the Add field button, check to see if the report contains fields. If not, close the
query dialog, register the fields, and resume the sorting.
This parameter contains the java.sql.Connection class passed to JasperReports from the calling program.
If you get a ClassNotFoundError exception, the most likely cause is that the required driver is not present
in the classpath. See 10.3.2.1, “ClassNotFoundError,” on page 152 for more information.
query language based on the JSON-like objects upon which MongoDB operates. JSON is the JavaScript Object
Notation, a textual representation of data structures that is both human- and machine-readable.
The Jaspersoft MongoDB Query Language is a declarative language for specifying what data to retrieve from
MongoDB. The connector converts this query into the appropriate API calls and uses the MongoDB Java connector
to query the MongoDB instance. The following examples give an overview of the Jaspersoft MongoDB Query
Language, with SQL-equivalent terms in parentheses:
• Retrieve all documents (rows) in the given collection (table):
{ 'collectionName' : 'accounts' }
• From all documents in the given collection, select the named fields (columns) and sort the results:
{
'collectionName' : 'accounts',
'findFields' : {'name':1,'phone_office':1,'billing_address_city':1,
'billing_address_street':1,'billing_address_country':1},
'sort' : {'billing_address_country':-1,'billing_address_city':1}
}
• Retrieve only the documents (rows) in the given collection (table) that match the query (where clause). In this
case, the date is greater-than-or-equal to the input parameter, and the name matches a string (starts with N):
{
'collectionName' : 'accounts',
'findQuery' : {
'status_date' : { '$gte' : $P{StartDate} },
'name' : { '$regex' : '^N', '$options' : '' }
}
}
The Jaspersoft MongoDB Query Language also supports advanced features of MongoDB such as map-reduce
functions and aggregation that are beyond the scope of this document. For more information, see the language
reference on the Community website.
When you create a report or subdatasource from a native MongoDB connection, Jaspersoft Studio automatically
selects MongoDbQuery as the query language. You can explicitly view and set the query language using the
Dataset and Query Dialog.
Figure 10-13 Example Dataset and Query Dialog for a MongoDB Data Adapter
This section describes functionality that can be restricted by the software license for JasperReports Server. If
you don’t see some of the options described in this section, your license may prohibit you from using them. To
find out what you're licensed to use, or to upgrade your license, contact Jaspersoft.
7. Click Test to check the values you entered. If everything's okay, you'll see this message:
When using AdhocEngineServiceImpl with input controls formatted values, some configurations that
require working with Google BigQuery data source are missed. To address this, configure
jasperReportContext as follows:
LocalJasperReportsContext jasperReportsContext = new LocalJasperReportsContext
(parentJasperReportsContext);
where <returnType> (the return value) is a generic Java class or a primitive type (such as int, double, and so
on).
different JavaBeans and to return them as a collection (java.util.Collection) or an array (Object[]). The
following example shows how you might create write an instance of the Factory class.
Suppose that you have an collection of JavaBeans, where the data is represented by a set of objects of type
PersonBean. The following table shows the code for PersonBean, which contains two fields: name (the person’s
name) and age:
To use this collection of beans, you need to create an instance of the Factory class. Your class, named
TestFactory, must contain the actual data that is used by the report. In this case, it will be something similar to
this:
return collection;
}
}
A data adapter based on this class would represent five JavaBeans of PersonBean type.
Create a new empty report and add the two fields by right-clicking the Fields node in the outline view and
selecting Add field. The field names and the types of the fields are: name (java.lang.String) and age
(java.lang.Integer).
Drag the fields into the Detail band and run the report. (Make sure the active connection is the
TestFactoryAdapter.) To refer to an attribute of an attribute, use periods as a separator. For example, to access the
street attribute of an Address class contained in the PersonBean, the syntax would be address.street. The
real call would be <someBean>.getAddress().getStreet().
If you selected Use field description when you specified the properties of your data adapter, the mapping
between JavaBean attribute and field value uses the field description instead of the field name.
Jaspersoft Studio provides a visual tool to map JavaBean attributes to report fields. To use it, open the query
window, go to the tab JavaBean Data Source, insert the full class name of the bean you want to explore, and
click Read attributes. The tab displays the attributes of the specified bean class.
• If an attribute is also a Java object, you can double-click the object to display its other attributes.
• To map a field, select an attribute name and click the Add Selected Field(s) button.
<addressbook>
<category name="home">
<person id="1">
<lastname>Davolio</lastname>
<firstname>Nancy</firstname>
</person>
<person id="2">
<lastname>Fuller</lastname>
<firstname>Andrew</firstname>
</person>
<person id="3">
<lastname>Leverling</lastname>
</person>
</category>
<category name="work">
<person id="4">
<lastname>Peacock</lastname>
<firstname>Margaret</firstname>
</person>
</category>
<favorites>
<person id="1"/>
<person id="3"/>
</favorites>
</addressbook>
To select only the people contained in the categories (that is, all the people in the address book), use the following
expression:
/addressbook/category/person
<person id="1">
<lastname>Davolio</lastname>
<firstname>Nancy</firstname>
</person>
<person id="2">
<lastname>Fuller</lastname>
<firstname>Andrew</firstname>
</person>
<person id="3">
<lastname>Leverling</lastname>
</person>
<person id="4">
<lastname>Peacock</lastname>
<firstname>Margaret</firstname>
</person>
If you want to select the people appearing in the favorites node, the expression to use is
/addressbook/favorites/person
<person id="1"/>
<person id="3"/>
Here's another expression. It's a bit more complex, but it shows all the power of the XPath language. The idea is to
select the person nodes belonging to the work category. The expression to use is the following:
/addressbook/category[@name = "work"]/person
The expression returns only one node, the one with an ID equal to 4, as shown here:
<person id="4">
<lastname>Peacock</lastname>
<firstname>Margaret</firstname>
</person>
You can configure an XML data adapter to connect to a REST web service. For an example of connecting to
a web service using the JSON adapter, see 10.9.2, “Connecting to a Web Service Using a JSON Data
Adapter,” on page 175.
6. Choose whether to provide a set of nodes using a pre-defined static XPath expression, or set the XPath
expression directly in the report.
We recommend using a report-defined XPath expression. This enables you to use parameters inside the XPath
expression, which acts like a real query on the supplied XML data.
Optionally, you can specify Java patterns to convert dates and numbers from plain strings to more appropriate
Java objects (like Date and Double). For the same purpose, you can define a specific locale and time zone to
use when parsing the XML stream.
For example, to define a field that must point to the id attribute of a person (attribute id of the node person), it's
sufficient to create a new field, name it, and set the description to:
@id
It's also possible to get to the child nodes of the current node. For example, if you want to refer to the lastname
node, child of person, use the following syntax:
lastname
To move to the parent value of the current node (for example, to determine the category to which a person
belongs), use a slightly different syntax:
ancestor::category/@name
The ancestor keyword indicates that you're referring to a parent node of the current node. Specifically, the first
parent of category type, of which you want to know the value of the name attribute.
Now, let’s see everything in action. Prepare a simple report with the registered fields shown here:
id @id Integer
Jaspersoft Studio provides a visual tool to map XML nodes to report fields; to use it, open the query window and
select XPath as the query language. If the active connection is a valid XML data adapter, the associated XML
document is shown in a tree view. To register the fields, set the record node by right-clicking a Person node and
selecting the menu item Set record node. The record nodes are displayed in bold.
Then one by one, select the nodes or attributes and select the pop-up menu item Add node as field to map them
to report fields. Jaspersoft Studio determines the correct XPath expression to use and creates the fields for you. You
can modify the generated field name and set a more suitable field type after the registration of the field in the report
(which happens when you close the query dialog).
Insert the different fields in the Detail band. The XML file used to fill the report is that shown:
The XPath expression for the node set selection specified in the query dialog is:
/addressbook/category/person
<addressbook>
<category name="home">
<person id="1">
<lastname>Davolio</lastname>
<firstname>Nancy</firstname>
<email>[email protected]</email>
<email>[email protected]</email>
<hobbies>
<hobby>Music</hobby>
<hobby>Sport</hobby>
</hobbies>
</person>
<person id="2">
<lastname>Fuller</lastname>
<firstname>Andrew</firstname>
<email>[email protected]</email>
<email>[email protected]</email>
<hobbies>
<hobby>Cinema</hobby>
<hobby>Sport</hobby>
</hobbies>
</person>
</category>
<category name="work">
<person id="3">
<lastname>Leverling</lastname>
<email>[email protected]</email>
</person>
<person id="4">
<lastname>Peacock</lastname>
<firstname>Margaret</firstname>
<email>[email protected]</email>
<hobbies>
<hobby>Food</hobby>
<hobby>Books</hobby>
</hobbies>
</person>
</category>
<favorites>
<person id="1"/>
<person id="3"/>
</favorites>
</addressbook>
What we want to produce is a document that is more elaborate than those you have seen so far. For each person,
we want to present their e-mail addresses, hobbies, and favorite people.
You can create this document using subreports. You'll need a subreport for the e-mail address list, one for hobbies,
and one for favorite people (that is a set of nodes out of the scope of the XPath query we used). To generate these
subreports, you need to understand how to produce new data sources to feed them. In this case, you'll use the
JRXmlDataSource, which exposes two extremely useful methods:
public JRXmlDataSource dataSource(String selectExpression)
public JRXmlDataSource subDataSource(String selectExpression)
The first method processes the expression by applying it to the whole document, starting from the actual root. The
second assumes the current node is the root.
Both methods can be used in the data source expression of a subreport element to dynamically produce the data
source to pass to the element. The most important thing to note is that this mechanism allows you to make both the
data source production and the expression of node selection dynamic.
The expression to create the data source that feeds the subreport of the e-mail addresses is:
((net.sf.jasperreports.engine.data.JRXmlDataSource)
$P{REPORT_DATA_SOURCE}).subDataSource("/person/email")
This code returns all the e-mail nodes that descend directly from the present node (person).
The expression for the hobbies subreport is similar, except for the node selection:
((net.sf.jasperreports.engine.data.JRXmlDataSource)
$P{REPORT_DATA_SOURCE}).subDataSource("/person/hobbies/hobby")
Next, declare the master report’s fields. In the subreport, you have to refer to the current node value, so the field
expression is simply a dot (.),
Proceed with building your three reports: xml_addressbook.jasper, xml_addresses.jasper, and xml_
hobbies.jasper.
In the master report, xml_addressbook.jrxml, insert a group named “Name of category,” in which you
associate the expression for the category field ($F{name of category}). In the header band for Name of
category, insert a field to display the category name. By doing this, the names of the people are grouped by
category (as in the XML file).
In the Detail band, position the id, lastname, and firstname fields. Below these fields, add the two Subreport
elements, the first for the e-mail addresses, the second for the hobbies.
The e-mail and hobby subreports are identical except for the name of the field in each one. The two reports should
be as large as the Subreport elements in the master report, so remove the margins and set the report width
accordingly.
Preview both the subreports just to compile them and generate the relative .jasper files. Jaspersoft Studio returns
an error during the fill process, but that's expected. We haven't set an XPath query, so JasperReports can't get any
data. You can resolve the problem by setting a simple XPath query (it isn't used in the final report), or you can
preview the subreport using the empty data adapter (select it from the drop-down in the tool bar).
When the subreports are done, execute the master report. If everything is okay, the report groups people by home
and work categories and the subreports associated with each person.
As this example demonstrates, the real power of the XML data adapter is the versatility of XPath, which allows
navigation of the node selection in a refined manner.
1. With your report open in the Design tab, click to open the Dataset and Query window.
2. Select the data adapter that points to your XML/A provider from the drop-down in the upper-left corner.
3. Select MDX from the Language drop-down.
4. Enter a valid MDX query in the text field.
To create a good MDX query, you must be familiar with both the language itself and the data you want to
work with. You can also use a tool (such as the Jaspersoft OLAP Workbench) to load your OLAP schema and
automatically generate MDX queries from it.
5. Click Read Fields.
Jaspersoft Studio returns the XML/A provider's data, including fields and parameters, and populates the
window's tabs with information. For more on how these tabs can be used to define the data in your report, see
Chapter 11, “Creating Queries,” on page 197.
Jaspersoft Studio also sets the class type of each field to an appropriate Java datatype. If Jaspersoft Studio sets
an incorrect datatype, you can set the correct type after the fields are added to your report.
6. When the data in the Data Preview tab looks like the data you want to fill your report, click OK to close the
Dataset and Query window.
If you define more columns than the ones available, you’ll get an exception at report filling time.
JasperReports assumes that for each row all the columns have a value (even if they are empty).
6. If your CSV file uses nonstandard characters to separate fields and rows, you can adjust the default setting for
separators using the Separators tab.
7. Click Finish.
10.9.2.2 The Data Adapter Tab in the Dataset and Query Dialog
When you create a report using a data adapter that connects to a web service, you see the following Data Adapter
tab in the Dataset and Query dialog:
This tab lets you configure the following information for the data adapter:
• Data URL – Base URI for the request.
• Username and Password – Credentials for web services that require authentication.
• Request method – The method to use for the data adapter. Supported methods are GET, POST, and PUT.
• URL Parameters tab – Parameters to append to the URI.
• POST/PUT Parameters tab – Parameters to send in the request body.
• POST/PUT Body tab – Data to send in the request body.
• Headers tab – Parameters to send in the HTTP header.
• The following additional information is shown:
• – The URL parameter in the data adapter has been associated with an HTTP parameter in the report. The
name of the report parameter is shown to the right.
where [token] is the web services token you request in the first step below.
This example uses a public API from a third party to generate a report. This API is not controlled by TIBCO,
Inc. and is subject to change without notice.
• token: Set Name to the NOAA parameter token and Value to the NOAA key you requested
previously.
10. Click OK.
11. Click Test Connection to verify the data can be received.
3. Enter the objects you want to use in your dataset. For this example, enter results. If you only wanted to get
the datatype values for each record, you could enter results.datatype.
4. Click Read Fields to load the list of fields in the dataset.
5. To optionally preview a subset of the data, select the Data preview tab, then click Refresh Preview Data.
6. Click OK.
10.9.3.1 Configuring a Parameter using the Parameters tab in the Dataset and Query dialog
1. Right-click the root node of your report and select Dataset and Query….
2. In the Dataset and Query dialog, click the Parameters tab.
3. Click to hide the system parameters.
4. Click Add to create a new parameter.
5. Select the parameter you just created, click Edit and enter the following, then click OK:
• Parameter Name – Location
• Is For Prompt – true (default)
• Class Type – java.lang.String (default)
• Default Value Expression – "ZIP:94111"
6. Click to display parameter properties.
7. Select your parameter and click Add Property. A dialog displays a list of properties available for a web
services data adapter.
10.9.3.2 Configuring a Parameter Using the Data Adapter Tab in the Dataset and Query Dialog
The names and default values you set for the URL parameters in your data adapter are shown on the Data Adapter
tab in the Dataset and Query dialog. You can use this tab to associate your HTTP parameter directly to a parameter
in the report.
1. Display your report in design view.
1. Right-click the root node of your report and select Dataset and Query….
2. In the Dataset and Query dialog, click the Parameters tab.
3. Click Add to create a new parameter. A new parameter is created with a name such as Parameter1.
4. Click the Data Adapter tab.
For this example, you see three data adapter parameters, one of which has been mapped to the Location
parameter in your report, shown with an icon .
5. Double-click the value field after enddate and click the icon that appears.
6. Select Parameter1 from the drop-down. This associates Parameter1 in the report with the enddate URL
parameter in the data adapter.
7. On the Parameters tab, select Parameter1 and click Edit. You see that the evaluation time and properties have
been set automatically. Enter the following and click OK:
• Parameter Name – End Date
• Default Value Expression – 2017-07-30
8. Click OK to exit the Dataset and Query dialog.
9. If you wish, you can preview the report. You are now prompted to enter a value for the end date as well as the
location. Make sure the end date you enter is after the default start date you entered when you created the data
adapter.
10. Click to run the report.
2. Set the number of empty records you need. Remember, whatever field you add to the report, its value is set to
null. Since this data adapter doesn’t care about field names or types, this is a perfect way to test any report
(keeping in mind that the fields are always set to null).
3. Click Finish.
The first constructor indicates how many records to return, and the second sets the number of records to one.
4. Name the adapter and set the number of records you need.
5. Click Finish.
To create a global random data adapter that you can use in different projects, go to the Project Explorer and
select New > Data Adapter from the context menu. Global data adapters can't be accessed from
JasperReports Server or JasperReports IO project types.
in example:
(com.jaspersoft.ireport.examples.beans.PersonBean)$F{my_person}
Usually a cast is required when you need to call a method on the object that belongs to a particular class.
package net.sf.jasperreports.engine;
public interface JRDataSource
{
public boolean next() throws JRException;
The next method is used to set the current record into the data source. It has to return true if a new record to
elaborate exists; otherwise it returns false.
If the next method has been called positively, the getFieldValue method has to return the value of the
requested field or null. Specifically, the requested field name is contained in the JRField object passed as a
parameter. Also, JRField is an interface through which you can get information associated with a field—the
name, description, and Java type that represents it.
Now try writing your personalized data source. You have to write a data source that explores the directory of a file
system and returns the found objects (files or directories). The fields you create to manage your data source are the
same as the file name, which should be named FILENAME; a flag that indicates whether the object is a file or a
directory, which should be named IS_DIRECTORY; and the file size, if available, which should be named SIZE.
You data source should have two constructors: the first receives the directory to scan as a parameter; the second
has no parameters and uses the current directory to scan.
Once instantiated, the data source looks for the files and the directories present in the way you indicate and fills the
array files.
The next method increases the index variable you use to keep track of the position reached in the array files, and
returns true until you reach the end of the array.
import net.sf.jasperreports.engine.*;
import java.io.*;
public class JRFileSystemDataSource implements JRDataSource
{
File[] files = null;
int index = -1;
public JRFileSystemDataSource(String path)
{
File dir = new File(path);
if (dir.exists() && dir.isDirectory())
{
files = dir.listFiles();
}
}
public JRFileSystemDataSource()
{
this(".");
}
public boolean next() throws JRException
{
index++;
if (files != null && index < files.length)
{
return true;
}
return false;
}
public Object getFieldValue(JRField jrField) throws JRException
{
File f = files[index];
if (f == null) return null;
if (jrField.getName().equals("FILENAME"))
{
return f.getName();
}
else if (jrField.getName().equals("IS_DIRECTORY"))
{
return new Boolean(f.isDirectory());
}
else if (jrField.getName().equals("SIZE"))
{
return new Long(f.length());
}
// Field not found...
return null;
}
}
The getFieldValue method returns the requested file information. Your implementation doesn't use the
information regarding the return type expected by the caller of the method. It assumes the name has to be returned
as a string. The flag IS_DIRECTORY as a Boolean object, and the file size as a Long object.
The next section shows how to use your personalized data source in Jaspersoft Studio and test it.
import net.sf.jasperreports.engine.*;
public class FileSystemDataSourceFactory {
public static JRDataSource createDatasource()
{
return new JRFileSystemDataSource("/");
}
}
This class, and in particular the static method that's called, executes all the necessary code for instancing the data
source correctly. In this case, you create a new JRFileSystemDataSource object by specifying a way to scan the
directory root ("/").
Now that you have defined the way to obtain the JRDataSource you prepared and the data source is ready to be
used, you can create the connection through which it can be used.
Create a new connection as you normally would (see “Working with Database JDBC Connections” on
page 150), then select Custom implementation of JRDataSource from the list and specify a data source
name like TestFileSystemDataSource (or whatever name you want), as shown below.
Next, specify the class and method to obtain an instance of your JRFileSystemDataSource, that is,
TestFileSystemDataSource and test.
There is no automatic method to find the fields managed by a custom data source.
In this case, you know that the JRFileSystemDataSource provides three fields: FILENAME (String), IS_
DIRECTORY (Boolean), and SIZE (Long). After you have created these fields, insert them in the report’s Detail
band.
Divide the report into two columns and in the Column Header band, insert Filename and Size tags. Then add two
images, one representing a document and the other an open folder. In the Print when expression setting of the
Image element placed in the foreground, insert the expression $F{IS_DIRECTORY}, or use as your image
expression a condition like the following:
($F{IS_DIRECTORY}) ? “folder.png” : “file.png”
In this example, the class that instantiated the JRFileSystemDataSource was very simple. But you can use more
complex classes, such as one that obtains the data source by calling an Enterprise JavaBean or by calling a web
service.
This version of Jaspersoft Studio was verified with Spotfire version 7.7. Other versions may also work but
have not been tested extensively.
You can also create reports against SBDFs ; to do so, select one from your Spotfire library.
6. If you have prompts in your information link and want to set their values using parameters in Jaspersoft
Studio, make sure Use a query (required to use parameters) is selected.
7. Click OK.
8. Click Test to test your connection.
9. If the test fails, check your URL, credentials, and resource ID.
10. When the test succeeds, click Finish.
It isn't uncommon for an Information Link to return millions of rows of data, which may take a some time for
Jaspersoft Studio to process when data is loaded, such as when previewing the report; the same may hold
true in JasperReports Server.
2. Select a server connection and navigate its repository to the desired location.
3. Optionally enter a new label, name (ID), and description of the report unit.
4. Click Next. You're prompted to select a resource used by the report, including the data adapter you exported
above.
5. Click Next. You're prompted to select a data source.
6. Select Don't use any Data Source. Since the data adapter has already been defined, the report doesn't need
a separate data source.
7. Click Finish. Jaspersoft Studio adds your report to the repository.
While it's uploaded, Jaspersoft Studio modifies your JRXML so that it will run properly on the server. In particular,
it changes how the data adapter is specified. On the server, the data adapter is uploaded to the folder you selected
when you published the report.
To test your report, open the server's web UI, locate your report, and click it to run it.
10.13.1.1 Configuring Jaspersoft Studio Parameters for Use With Spotfire Prompts
The Dataset and Query dialog shows the prompts for your Spotfire Information Link. You must configure
parameters for your prompt based on the Type and Extra values.
Range
Class Type – java.lang.String
Default Value Expression – The default value expression must be two Strings with a caret (^) between them.
Most often, you will want to create three parameters in Jaspersoft Studio: two parameters that define the endpoints
of the range and a third parameters of type String that is used to pass the Range to Spotfire. The endpoint
parameters should correspond to the Type of the prompt.
For example, for a Range prompt of type DateTime, you might create two parameters of type
java.sql.Timestamp that are used to take input for the start and end time:
Then you would create a dependent parameter that uses these two parameters to construct a String to pass to
Spotfire:
Multiple selection
Class Type – java.util.Collection; the objects in the collection should correspond to the Type of the
prompt. The data adapter mechanism formats the Collection contents appropriately.
Sample Default Value Expression – Arrays.asList(1,2,3,4,5,6,7)
Single selection
Class Type – Corresponds to the Type for the prompt. Numbers (and Currency) are passed with a “9.9999”
format; no $ or , are used.
Use the Dataset and Query dialog to configure your dataset as follows:
• Select a data adapter from the menu next to the icon. Usually a data adapter is selected, but you can change
it.
• Select a query language for the current dataset from the Language menu. (This can be the main dataset or a
sub-dataset that populates a chart or a table.)
• Enter a query. A query editor is available for several languages including SQL, XPath, JSON, and the Ad Hoc
Query API query language.
• Click Read Fields to have Jaspersoft Studio discover fields for you. These can be provided directly by the
data adapter or by executing the query and reading the response metadata.
For certain types of data adapters, below the data adapter menu let you view additional information about the data
adapter.
• For Java bean data sources, view the configuration on the Java Bean tab.
• For data adapters that get their information via a web service, use the Data Adapter tab.
The tabs at the top provide the user interface for working with your data adapter:
• Query tab – Displays a language and query editor that helps you construct the query for your dataset.
• Java Bean tab – Displays a tool that helps you introspect a Java class and build dataset fields from the fields in
the class. This is useful for Java data sources.
• Data Adapter tab – Displays any additional user interface specific to the chosen data adapter type.
Use the tabs at the bottom to perform the following additional tasks:
• Add, edit, or remove fields on the Fields tab.
• Add, edit, or remove parameters on the Parameters tab. See 6.1.1.2, “Managing Parameters Using the
Parameters tab in the Dataset and Query Dialog,” on page 95 for more information.
• Edit sort options for dataset records on the Sorting tab.
• Provide an expression to filter dataset records on the Filter Expression tab.
• Preview your data on the Preview tab, if supported by the selected data adapter.
11.1.1 Configuring the Data Adapter and Query Language Drop downs
By default, the Dataset and Query dialog shows all available data adapters and all available query languages.
However, you can change this using the icon next to the data adapter menu as follows:
• To show all available data adapters and query languages, click and choose Show All Data Adapters
(default).
• To choose a data adapter and restrict the query languages to ones compatible with the chosen data adapter,
click and choose Show Languages For Data Adapter.
• To choose a query language and restrict the view to compatible data adapters, click and choose Show Data
Adapters For Language.
• To configure this setting globally, click and choose Global Preferences, then make your selection in the
Preferences dialog.
This tab lets you configure the following information for the data adapter:
• Data URL – Base URI for the request.
• Username and Password – Credentials for web services that require authentication.
• Request method – The method to use for the data adapter. Supported methods are GET, POST, and PUT.
• URL Parameters tab – Parameters to append to the URI.
• POST/PUT Parameters tab – Parameters to send in the request body.
• POST/PUT Body tab – Data to send in the request body.
• Headers tab – Parameters to send in the HTTP header.
• The following additional information is shown:
• – The URL parameter in the data adapter has been associated with an HTTP parameter in the report. The
name of the report parameter is shown to the right.
• – The URL parameter in the data adapter has a default value.
use the proper data adapter: for example to execute an SQL query you must use a JDBC data adapter. The Read
Fields button starts the discovery process: the fields found are listed in the Fields tab and added to the report.
Click OK to close this window.
Some query languages, like XPath, do not produce a result that resemble a table, but more complex structures that
require extra steps to correctly map result data to report fields. An example of this is the multidimensional result
coming from MDX results (MDX is the query language used with OLAP and XML/A connections): in this case
each field is mapped using one or more properties depending on the requirements of the data. For some languages,
such as instance XPath and JSON query, the Query dialog displays a tool that simplifies the creation of both the
query and the mapping.
The Outline view is a good tool for people with a basic understanding of SQL. It works in conjunction with the
Diagram view, which represents the simplest way to design a query. In the outline view the query is split in its
main parts introduced by the relative keyword. Those parts include:
SELECT introduces the portion of query where are listed all the columns that form a record of the final result set
(which is basically a list of records).
FROM contains the list of tables involved in our queries and if specified the rules to join that tables.
WHERE is the portion of query that describes the filters and conditions that the data must satisfy in order to be part
of the final result, conditions can be combined by using the OR and AND logical operators and can be aggregated by
using parentheses.
GROUP BY indicates a set of fields used to aggregate data and is used when an aggregation function is present in
the SELECT. For example, the following query counts the number of orders placed in each country.
SELECT
count(*) as number_of_orders,
Orders.country
FROM
Orders
GROUP BY
Orders.country
HAVING works a bit like a WHERE, but it's used with aggregate functions. For example the following query filters
the records by showing only the countries that have at least 40 orders:
ORDER BY specifies a set of columns for sorting the result set.
SELECT
count(*) as number_of_orders,
Orders.country
FROM
Orders
GROUP BY
Orders.country
HAVING
count(*) > 40
The Diagram view shows the tables in the query with the relative join connections and the selected fields. This
view is very useful especially to select the relevant fields and easily edit the table joins by double-clicking the
connection arrows.
Aliases are useful when you have several fields with the same name coming from two different tables.
You can also edit joins in the outline view by right-clicking a table name and selecting Add or Edit Table Join.
You can organize conditions by creating condition groups, and then combining them with or and and operators. At
least one condition must be true for an OR group. All conditions must be true for the AND operator. You can double-
click to change the value of either of these group operators.
If the value of a condition is not fixed, you can express it by using a parameter with the expression: $P
{parameter_name}.
When using collection type parameters, the $X{}expressions allow you to use operators like IN and NOT IN,
which determine whether a value is present in the provided list. The $X{} syntax also allows you to use other
operators like BETWEEN for numbers, Date Range and Time Range type of parameters. See 8.2, “Expression
Operators and Object Methods,” on page 118 for more information about the $X{} syntax.
You can connect Jaspersoft Studio to JasperReports Server and move reports between the two. Jaspersoft Studio
uses web services to interact with the server.
Connecting with JasperReports Server enables you to:
• Browse the repository on the server from Jaspersoft Studio.
• Add reports and subreports to the repository from Jaspersoft Studio.
• Drag and drop images and other resources from the repository to Jaspersoft Studio.
• Add and delete folders and resources on the server from Jaspersoft Studio.
• Modify resource properties on the server from Jaspersoft Studio.
• Link input controls to reports on the server.
• Import and export data sources (JDBC, JNDI, and JavaBean).
• Download, edit, and upload JRXML files.
• Connect to multiple servers for access to both test and production environments.
• Create a report in Jaspersoft Studio based on a Domain in JasperReports Server (commercial edition only).
This chapter contains the following sections:
• Connecting to JasperReports Server
• Configuring a Project for JasperReports Server
• Publishing a Report to JasperReports Server
• Working with JasperReports Server Templates
• Creating and Uploading a Topic for Ad Hoc Views
• Managing Repository Objects through Jaspersoft Studio
• Creating and Uploading Chart Themes
• Working with Domains
• Understanding the repo: Syntax
• Adding a Date/Time Stamp to Scheduled Output in JasperReports Server
3. Enter the URL, user names and password for your server. If the server hosts multiple organizations, enter the
name of your organization as well.
The defaults are:
• URL:
• Commercial editions: http://localhost:8080/jasperserver-pro/
• Community edition: http://localhost:8080/jasperserver/
The Server profile wizard automatically detects a server connection beginning with https and
displays a icon. See 12.1.2, “Connecting to JasperReports Server Over SSL,” on page 210
for more information.
• Organization: There is no default value for this field. If the server hosts multiple organizations, enter the
ID of the organization to which you belong.
• User name: jasperadmin
• Password: jasperadmin
Note that if you are upgrading from a previous version of Jaspersoft Studio, the old URL
(http://localhost:8080/jasperserver-pro/services/repository ) still works.
4. Click Test Connection.
5. (SSL connections only.) If you are connecting over SSL, the SSL certificate is displayed. To add the certificate
to your trust store, click Trust. If you do not click Trust, the certificate will be displayed each time you
connect to this JasperReports Server instance. See 12.1.2, “Connecting to JasperReports Server Over SSL,”
on page 210 for more information.
6. If the test fails, check your URL, organization, user name, and password.
Connection problems can sometimes be caused by Eclipse's secure storage feature, which improves your
security by storing passwords in an encrypted format. For more information, refer to our Eclipse Secure
Storage in Jaspersoft Studio Community wiki page.
7. If the test is successful, click Finish.
The server appears in the Repository Explorer.
• Use Protocol – Set the web services protocol to use between Jaspersoft Studio and the server. The SOAP
format does not support single sign-on.
• Supports DateRange Expressions – Lets you upload queries with relative dates to JasperReports Server.
See 6.3.4, “Relative Dates ,” on page 102 for more information.
• Synchronize DataAdapter Properties – Synchronizes the net.sf.jasperreports.data.adapter
property with the Jaspersoft Studio data adapter setting.
• Format of Attachments – Sets the message attachment format to MIME or DIME.
• Workspace Folder – Lets you designate the folder in the workspace where you want to store files
downloaded from this JasperReports Server instance.
• Locale – Sets the locale to use for the Jaspersoft Studio connection to the server.
• Time Zone – Sets the timezone to use for the Jaspersoft Studio connection to the server.
• Info tab – Shows information about the JasperReports Server instance, including version number, edition,
license expiration, licensed features, and data and timestamp format.
You can also open the Trust Store dialog when you are creating a secure connection by clicking Show Trust
Store in the Security Certificate dialog.
The Trust Store dialog lets you do the following:
• To view a certificate and its certificate chain, select the certificate.
• To remove a certificate from the store, select the certificate and delete it.
5. Click OK.
The CAS server is added to the list of available single sign-on servers.
6. Click OK.
4. If the server hosts multiple organizations, enter the ID of the organization to which you belong. This can be the
root organization (in which case you can leave this entry bar blank) or another organization.
5. Select the CAS server you want to use for this connection from the SSO Server menu.
6. Click Test Connection to test the connection. This may take some time, especially the first time you
connect.
7. Click OK in the confirmation dialog.
8. Click OK to create the connection.
The JasperReports Server context is only a simulation; it does not include all the classes and structure of
JasperReports Server.
4. In the Workspace Folder section, browse to the project you want to associate with this server instance.
5. Click Finish.
3. Expand the folder for your report. You will see the local resources for the report.
4. Open the Main.jrxml file in the editor. You can do this by double-clicking on the file, or by right-clicking the
file and selecting Open in Editor.
5. When you open the Main.jrxml file in the editor, the report and all its resources are copied to the associated
project in Jaspersoft Studio. The path for the report in the repository is duplicated in the Jaspersoft Studio
project. To see this, open the Project Explorer and navigate to the associated folder.
are published to a repository location, and the uploaded report uses the repo: syntax to refer to the report
location.
• Type – When Overwrite is selected, specifies the existing resource to overwrite. Click on the value in this
column to display a drop-down menu with the following choices:
• Save to Folder – Save to a location anywhere on your JasperReports Server instance. When you choose
this option, you are prompted to navigate to the location you want.
• Link to Resource – Links to an existing resource on your JasperReports Server instance. When you
choose this option, you are prompted to navigate to the resource you want. If you modify a report and the
report is set to Overwrite, changes overwrite only the path, not the resource.
• Use Local Resource – Save as a resource inside the report unit on JasperReports Server.
If you are using a JDBC or JNDI data source, make sure that your connection uses the same driver as your
Jaspersoft Studio data adapter. For example, if you connect to an Oracle database from a commercial edi-
tion, you can download and use the native Oracle driver or you can use the TIBCO Oracle JDBC driver that is
included with Jaspersoft Studio. If your driver in JasperReports Server does not match the driver used in
Jaspersoft Studio, you could see different data in your uploaded report.
• Click to publish your report and select a JasperReports Server instance and repository location where you
want to save the report. Then click OK. If you are prompted to upload resources, select your settings.
• Select Data Source from Repository when prompted.
• Click ... and select the correct JasperReports Server data source from the repository.
• If you want to use a JNDI data source, first set up the JNDI connection for your database in your application
server. Make sure to use the same JDBC driver for your Jaspersoft Studio adapter and the JNDI connection in
JasperReports Server.
• Click to publish your report and select a JasperReports Server instance and repository location where you
want to save the report. Then click OK. If you are prompted to upload resources, select your settings.
• Select Local Data Source when prompted.
• Click ... to open the Add Resource wizard.
• Select the type of data source you want to create , for example, Datasource JDBC, and click Next.
• On the Resource Editor page, enter a name and unique ID for the data source. You can also enter an optional
description. Then click Next.
• On the next page, manually fill in the required information for the data source you want to create.
• Click Finish to create the data source and use it in your uploaded report.
For some types of data sources, such as JDBC, JNDI, and bean data sources, you can publish a data adapter from
Jaspersoft Studio and set it as the data source for the report:
• Make sure that the data adapter you want to upload is saved locally as an xml file in the same project as your
report. See 10.1.2, “Importing and Exporting Data Adapters,” on page 145 for information about exporting
a global data adapter to your project; see 10.1.3, “Copying a Data Adapter,” on page 146 for information
about copying a data adapter from one project to another.
• Click to publish your report. Select a JasperReports Server instance and repository location where you
If you are using a custom data adapter or any other adapter that uses one or more jars that aren't included in
JasperReports Server, add the jar(s) to a location on your server classpath.
• Where possible, use inheritance to reduce the number of times you actually set the default data adapter. If
your report uses a specific adapter multiple times, try to structure the report so that the data adapter is set
for a single dataset and other datasets inherit it. For example, if you have a crosstab and a table that use
the same data adapter, you could create a subreport that contains the table and crosstab. Then if you set
your data adapter as the default for the subreport, the table and crosstab inherit this adapter. Reusing the
data adapter improves performance when you run the report.
• Publish your report and select No Data Source when prompted.
• When you publish the report, the default data adapters are uploaded to the repository.
Wizard opens.
6. Select any resources you want to upload with your report and check the box if you want to overwrite previous
versions of those resources. Click Next. The Configure the data source window opens.
7. Select a data source configuration. See 12.3.2, “Choosing a Data Source for a Published Report,” on
page 218 for more information.
8. Click Finish. The report is uploaded to the server. If there are no errors, an appropriate message is shown.
This section describes functionality that can be restricted by the software license for Jaspersoft Studio. If you
don’t see some of the options described in this section, your license may prohibit you from using them. To find
out what you're licensed to use, or to upgrade your license, contact Jaspersoft.
JasperReports Server includes several templates that affect the layout of your reports. You can add custom
templates to your JasperReports Server instance by uploading a JRXML file to a Templates directory. In addition
to font and color choice, templates can contain images such as logos. In a JasperReports Server template, the
absolute path of an image is in the repository and cannot be overwritten. Other users can apply your template by
selecting Custom Report Template when they create a report from an Ad Hoc View.
JasperReports Server templates are different from report templates in Jaspersoft Studio. See Chapter 24,
“Report Templates,” on page 457 for more information.
To create a template:
1. Connect to JasperReports Server as superuser.
2. In the Repository Explorer, navigate to the Public/Templates directory.
The document will look empty, but if you click the Source tab, you see that attributes are set at the JRXML
level. Note the attributes for ChartTitle:
<style name="ChartTitle" forecolor="#000000" fontName="DejaVu Sans" fontSize="12"
isBold="true"/>
You can edit styles directly on the Source tab if you choose.
4. Click the Design tab and in the Outline view, click the arrow next to Styles.
5. Click ChartTitle. The styles open in the Properties view.
You can link to an image in your template by uploading the image to the repository and then dragging it into
the appropriate band in the template. The template uses the absolute path to the image in the repository and
the image cannot be changed or overwritten.
For example, click Upload/Download Resource, click Upload from Workspace, select the my-
topic.jrxml file.
7. Click OK to close the upload window and click Next.
8. Click the Data Source from Repository radio button and click to its right.
9. Navigate to Analysis Components > Analysis connections, select the SugarCRM data source, and click
OK.
10. Click Finish to upload the report unit to the Topics folder so it can be used in the JasperReports Server Ad
Hoc Editor.
If the Topic includes fields with unusual datatypes, those fields don't appear in the Ad Hoc Editor because
JasperReports Server is not equipped to manage them properly. For example, if the Topic is defined against
a MongoDB instance that returns data of type array, this field isn't available in the Ad Hoc Editor. For more
information on datatype support in the Ad Hoc editor, see the JasperReports Server Administrator Guide.
When you create a JRXML file for use as a Topic, you can specify the name to display for each field the Topic
returns. To do so, define a field property named adhoc.display for each field declared in the JRXML. The
adhoc.display field property must have the following syntax:
<property name=”adhoc.display” value=”Any Name”/>
For example, this JRXML code declares a StoreState field displayed in reports as Store State:
Topics also support the $R expressions for field names; for more information, see Chapter 8, “Expressions,” on
page 117.
For fields in a non-domain topic the following properties may be of interest:
• dimensionOrMeasure, which marks a field as a field or a measure
• defaultAgg, the aggregation to use for this measure (for example, avg)
• semantic.item.desc, a description of the field
• DefaultMask, which sets a measure as a $ or date
If you choose to add an item other than a JasperReport, a dialog allows you to enter information about the
object. If you choose to add a JasperReport, a wizard guides you through the process. For the best
results when adding a JasperReport, open the JRXML in Jaspersoft Studio and click . Follow the
steps in the wizard to publish your report. See 12.3, “Publishing a Report to JasperReports Server,”
on page 217
• To add an Azure certificate, right-click a folder, select New, then select Azure Certificate. Similarly, you can
add a secure file.
If you are logged in as a user with sufficient access rights (such as jasperadmin or superuser), you can
modify property values and save them back to the repository.
The JRXML is stored locally in your workspace. The default location is in the user directory of your operating
system. For example, in Windows, the default workspace is
C:\Users\<username>\JaspersoftWorkspace\MyReports.
2. Edit the file, either in the Design tab or in the Source tab. For example, in the Repository Explorer
navigate to the Images\JR Logo image resource, and drag it into to the report's Title band. The logo appears in
the Design tab.
3. Click Save. If you're prompted to publish the report, click Yes.
4. Specify a server and a repository location. To save the JRXML to the same report unit where you opened it,
click Next.
If the report relies on resources, you're asked if you want to overwrite the resources currently in the repository.
If you added resources to the report, you are prompted to add them to the repository.
5. Click Next. and specify a data source for the report. You can't change a data source through the Publish
wizard.
Click Finish. Your changes are saved to the repository.
Input controls can be created in the JasperReports Server repository and referenced in reports. If you want to
use an input control from JasperReports Server in a report, the input control must meet two conditions:
• The parameter name in the input control must correspond to the name of the parameter in the report. No
error occurs for a mismatch, but at run time NULL is passed instead of actual value of the parameter.
• The input control and its corresponding parameter must be of compatible datatypes (for example, both
must be text types or date types). If there is a mismatch, the report fails and an exception is returned.
See the JasperReports Server Administrator Guide for more information.
6. You can also use the JSP field to modify the appearance of the controls. Specify a name of a JSP file in WEB-
INF of the server's host to define the page that displays input controls.
7. Click Finish.
Jaspersoft Studio supports only the most common options provided by JFreeCharts.
4. In the Outline view, select each category and review the available options in the Properties view.
5. Select a property to change its value.
Depending on the nature of the property, you might type text, select a color, check or clear a check box, or
select a value from a drop-down. As you update the chart theme, the Preview tab shows your changes. For
example, select Title in the Outline view and choose Bottom from the Position drop-down to move the title
beneath the chart.
6. Click a chart type in the Preview tab to zoom in to examine the effects of your changes more closely. Click
again to zoom out.
7. To view the XML that defines the chart theme’s appearance, click the Source tab.
8. When you are satisfied with the chart theme, click File > Save to save the chart theme. This saves the chart
theme to your local hard drive.
2. Choose the location where you want to save your JAR. To upload to an instance of JasperReports Server,
select your server instance and then select the Templates directory. To create a jar on your current system,
select a location on your hard drive.
3. Enter a file name and theme name for your theme.
4. If you want to use the theme to design reports on your current system, save to a location on your hard drive
and select Add the jar to the CLASSPATH to use the theme in the report designer.
5. Click OK. The chart theme is exported as a JAR.
Once you have uploaded a theme to JasperReports Server, you can use the repo: syntax in your reports to
specify this JAR as your chart theme. The theme can be used at the report or server level in JasperReports
Server. For more information, refer to the JasperReports Server Administrator Guide.
This section describes functionality that can be restricted by the software license for JasperReports Server. If
you don’t see some of the options described in this section, your license may prohibit you from using them. To
find out what you're licensed to use, or to upgrade your license, contact Jaspersoft.
Domains are structures for managing data in JasperReports Server. They connect to a normal data source and select
tables and colums, join them to others, arrange the results into business-related sets, give them meaningful labels,
and provide access security based on users and roles. Through the server UI, users can then create reports
interactively with the Ad Hoc editor, and the Domain acts as the data source, providing a curated view of your
database.
Jaspersoft Studio can also create reports based on Domains defined in JasperReports Server. Such reports use a
data adapter to load data accessed through a Domain. Then there are two different query languages you can use
with a Domain: the "jasperQL" query language and the earlier "domain" query language.
The jasperQL language was introduced in version 7.8 and has better support for input controls and lets you order
records by a field and limit the number of records shown. You can also group by one or more fields in the Dataset
and Query dialog. Jaspersoft recommends using the more advanced jasperQL language.
Before your report can access a Domain with either query language, consider the following requirements:
• Make sure your Domain is fully defined and saved on the server. For information about creating Domains, see
JasperReports Server Data Management Using Domains. The examples in this section use the supermart
sample Domain.
• Make sure your JasperReports Server is online.
• Optional: Define the server profile or connection object, as described 12.1, “Connecting to JasperReports
Server,” on page 208. You do not need the server profile to create and run a Domain report, but you will need
it to publish the report back to the server.
• Create a data adapter for the server connection, as described in the next section. The data adapter may also
identify the Domain on the server, or the report may specify the Domain.
Alternatively, you can edit the empty Jaspersoft Server Data Adapter that is created by default as a template.
Double-click it in the Repository Explorer panel to open it for editing in the Data Adapter Wizard.
2. Enter a name for the data adapter, usually the name of the Domain.
3. Enter the URL to access your server, ending in jasperserver-pro/, or click to select from the list of saved
servers.
4. Enter the username and password to access your server. If you access a Domain in an organization, specify the
credentials of a user or administrator in the organization, including the organization name or alias. It is good
practice to use the creditials of the least permitted user who still has access to the Domain or Domains you
want to access. If you have reports with different Domains using the same data adapter for this server, make
sure the user has access to all Domains and all the data that you need in the Domains.
A Domain may restrict access to its data based on the user who accesses the data. Restrictions can be
based on usernames, roles, attributes, or any combination of these. Depending on how your Domain is
defined, the credentials you choose here may affect the data that appears in reports that use this
adapter. If you access multiple Domains, the data from each of them may be affected by the user given
here.
5. Click Test to make sure your server is accessible and the credentials are valid.
6. Optional: enter the repository URL of your Domain or click to browse for it. If you only access one Domain
on the server, specify it here. If you have serveral Domains, each report can specify the Domain that it uses.
When browsing, you can enter a name and select it from the results, or navigate the repository tree that is
accessible to the user you specified. Mouse over a resource to see its description and details.
The default query language is jasperQL. You can select a different Domain on the server if needed, and the
dialog updates the available fields. The Domain being used is stored in the report itself, therefore it may be
different from the one in the data adapter.
6. Select fields or folders in the Domain on the left of the dialog, and drag them to the Fields item on the right to
create fields. For example, drag Sales > Stores.
The items are added as a flat list, using the labels from the Domain. At this point, you can refine the query by
adding fields to filters, group by, and order by headings. These actions are covered in detail in then next
section, Using the jasperQL Query Designer.
7. When done, click Next to select the dataset fields. These are the fields that appear in the report outline for use
in creating the report. In this simple example, click to add all fields.
Figure 12-27 Fields of the Query Result Selected for the Report
8. Click Finish and the report appears in a new tab with a blank canvas. The elements and fields of the report
appear in the report outline. When you mouse over the fields, you see the field's label from the Domain.
9. Define your report as usual, using the Palette and Outline to add and organize components.
10. Click Preview to test your report. Jaspersoft Studio compiles your report; if it's successful your report is filled
and displayed.
11. You will be prompted to publish your report upon save, or click to publish your report. For more
information, see 12.3, “Publishing a Report to JasperReports Server,” on page 217.
After a Domain-based report has been created, you can always go back and change or refine the query by right-
clicking the root of the report in the Outline panel, and selecting Dataset and Query... If you want to use input
controls in your report, define the corresponding parameters in your report before adding them as a filter in this
dialog. When the report uses a Domain data adapter and the jasperQL query language, the center of the dialog
contains the jasperQL query designer:
Figure 12-29 Editing a jasperQL Query in the Dataset and Query Dialog
The panel at the bottom of the Dataset and Query dialog displays the fields that are selected from the query results
(the dataset) for use in the report. If you configure the jasperQL query fully, you will reduce the results so they
contain exactly the fields you need. In that case, click the Read Fields button, to "read" all the query result fields
into the report, and they will replace any in the Fields tab at the bottom.
The panel at the bottom also has a Data Preview tab for testing the query. Use its controls to run the query and
see the values returned for the fields you've chosen or created. For example, this lets you check your aggregation,
grouping, and expected calculated field values. This is particularly useful to test any DomEL expressions in your
query elements.
The query designer has a Text tab that displays the text of the current query for information purposes. The
jasperQL query is a JSON text that is sent to the server through a private API. The syntax of the JSON is also
private, and editing the query on the text tab is not recommended.
On the Designer tab, you can create a query of your Domain by dragging and dropping fields, entering
expressions, and clicking for certain actions. The elements of the query are structured like an SQL query. The
result is a query that is easy to create and easy to interpret:
Use the following interactive features of the jasperQL query designer to create your query:
To remove a field from the list under the Fields heading, or any other heading on the right side, right-click the
field and select Delete from the context menu. You can also select the field and use the Delete key.
To specify distinct values for all fields returned by the query, right-click the Fields heading and select Set/Reset
DISTINCT. You can also double-click the Fields heading to toggle the setting.
The alias is also useful for giving fields a simple name wherever they appear in Jaspersoft Studio, otherwise the
fields are known by their ID, for example: sales_fact_ALL.sales.store_features.store_sqft.
Type the comparison value for the filter or click ... to select from a list of available values. Jaspersoft Studio
queries the data through the Domain to display the list. The results include rows of data for other fields chosen so
far. Double-click any row to insert the bolded value as the comparison value in the filter.
Alternatively, you can right-click the comparison value field and select Parameter or Function to use JasperReports
parameters or functions that you have already defined. Each of those options brings up a dialog where you can
specify the parameter or function. For example, parameters can be used to compare values against input controls
that you have defined in the report. When using parameters in filters, be sure to define default values for the
parameters to avoid unexpected errors.
For more information on parameters, see Chapter 6, “Parameters,” on page 93.
Repeat these steps for each filter you want. For the second filter and each one thereafter, a menu in the filter
expression dialog lets you choose to AND or OR your filter with the previous one.
To change the operator or value of a filter, double-click it on the right-hand panel. You can also drag filters to
change the order of composition. Finally, you can double-click the Filters heading and select Replace DomEL
Filter. This special filter allows you to write DomEL expressions on both sides of the operator and compare them.
jasperQL query, you will need to rewrite the query after switching the language setting. In some cases such as
aggregation where the report had to be configured a certain way because the domain-language did not support
aggregation, you will need to rewrite parts of the report. However, the report will be simplified because the
aggregation can be done by the query.
<imageExpression class="java.lang.String">
<![CDATA["repo:AllAccounts_Res2"]]>
</imageExpression>
When you publish a report to JasperReports Server and upload your resources, Jaspersoft Studio updates the
JRXML in the published report to use the repo: syntax to refer to the uploaded resources in the repository.
• repo: used with a path – A resource saved somewhere in the repository. For example, to refer to an image in
the repository, you might see JRXML like this:
<imageExpression class="java.lang.String">
<![CDATA["repo:/Images/myimage.jpg"]]>
</imageExpression>
In a multi-organization deployment of JasperReports Server, the path used in a repo: expression is relative to
the organization of the current user. For example, if User1 in Organization_1 accesses the report,
JasperReports Server looks for myimage.jpg in the Images folder of Organization_1. If User2 in Organization_
2 accesses the report, JasperReports Server looks for myimage.jpg in Images folder of Organization_2.
5. Drag the _ScheduledTime element from the Outline View to a valid location, such as the Title Band, in the
Designer:
6. Now you can set other properties, such as the text color of the date/time stamp. In Properties, check Blank
when Null to prevent the word null from appearing on the report when it runs unscheduled.
7. Compile the report, and upload it to JasperReports Server. For more information about uploading reports to
JasperReports Server, see “Accessing JasperReports Server from Jaspersoft Studio” on page 207.
8. In the server, schedule the report to run immediately.
9. Open the output file.
Figure 12-45 Output Showing the Scheduled Time the Report Actually Ran
The date and time the report actually ran appears in the output, as well as the scheduled time. In the screenshot
above there was a 13-second delay between the scheduled start time and the actual run time.
JasperReports IO is a REST-based reporting service for JasperReports Library, providing an interface to the
JasperReports Library reporting engine through the use of a REST API and a JavaScript API. You can build report
templates for JasperReports IO and test them using Jaspersoft Studio's built-in JasperReports IO reporting engine.
After previewing your reports you can export the templates and resources to an external folder to use with
JasperReports IO.
This chapter contains the following sections:
• JasperReports IO Repository File System
• JasperReports IO Report Execution Contexts
• Testing Reports with JasperReports IO
The built-in JasperReports IO preview engine only works for files located in your workspace. It is not
available for previewing linked files outside your workspace.
JasperReports IO comes with sample reports and resources in its repository for you to use.
Directory Description
data Contains the data source adapters and data source files for your reports. JasperReports IO
supports the following types of data adapters:
• JDBC connection
• CSV connection
• Excel connection
• Empty connection
• JNDI connection
• Remote XML connection
You can create your own data adapters for JasperReports IO either by using the DataAdapter
Wizard or by creating a custom data adapter using an XML file. See “Creating and Editing Data
Adapters” on page 144 for more information.
JR-INF Contains the configuration files for report execution. See “JasperReports IO Report Execution
Contexts” on page 250 for information on creating the files.
<context>
<parentContext>
<path>/parent</path>
</parentContext>
...
</context>
The path needs to specify the absolute repository path to the parent folder containing the target JR-INF context
that you want to use as parent context. Notice that the path specifies only the parent folder of the target report
execution context and does not specify the JR-INF folder.
For example, if you want the report execution context located at /samples/reports/chartcustomizers/JR-
INF/context.xml to inherit from the context located at /samples/reports/unicode/JR-INF/context.xml, you need
to add the following to the context.xml file:
<context>
<parentContext>
<path>/samples/reports/unicode</path>
</parentContext>
...
</context>
The report execution context will also inherit from the parents of the specified context, up to the root folder of
the repository.
13.2.1.2 Classpath
As a Java reporting library, JasperReports has various extension points which allow the customization of its
functionality using custom code in the form of compiled Java classes.
These classes are among the various types of resources that a report might need at execution time and they can also
be stored in the repository, along with the subreports, style templates, images, fonts and other report resources.
The custom Java classes needed during a certain report execution need to be packaged as JAR files and placed in
the repository, preferably under the JR-INF/lib subfolder of the report execution context that uses it.
The JAR then needs to be referenced from within the target context.xml file using a pair of <entry><path> tags
within the <classpath> tag so that it will be loaded by the JasperReports IO reporting service when it runs the
report.
For example, a report can use the custom Java code packaged in /samples/reports/chartcustomizers/JR_
INF/lib/repo-sample.jar JAR file when it's referenced in the context.xml file as follows:
<context>
<classpath>
<entry><path>/samples/reports/chartcustomizers/JR-INF/lib/repo-sample.jar</path></entry>
</classpath>
...
</context>
13.2.1.3 Properties
JasperReports IO can use JasperReports Library configuration settings to define specific behavior in reports.
Some of these configuration settings can be set at the report context execution level by using the <property> tags
in the context.xml file.
The following is an example of setting the chart render type configuration property:
<context>
...
<properties>
<property>
<name>net.sf.jasperreports.chart.render.type</name>
<value>svg</value>
</property>
...
</properties>
</context>
To edit a Report Execution Context Using the Report Execution Context Editor:
1. Right-click on the context file in the Project Explorer and select Open With > JasperReports IO
Report Execution Context Editor.
OR
Double-click the context file.
Jaspersoft Studio opens the context file in the editor.
The options under Advanced allow you to create links to files located outside of your workspace. However,
the built-in JasperReports IO preview engine only works for files located in your workspace. It is not available
for previewing linked files located outside your workspace.
> JasperReports IO. Jaspersoft Studio can now preview these reports with the JasperReports IO web application
server.
You can change the repository type of any folder in your workspace to one of the following: JasperReports
IO, JasperReports Library, or JasperReports Server. This allows you to design and test your reports in
different environments.
If you have multiple JasperReports IO projects in Jaspersoft Studio, each one uses its own web application
server. You can have multiple JasperReports IO instances running on different ports at the same time until
you delete a project or close Jaspersoft Studio.
Jaspersoft Studio starts a web application server for the first time when you preview a report with
JasperReports IO. One server per project uses a free default port 58080. In case you want to change the port
range, you can do it from the preference page and restart studio.
Exporting the HighCharts-based report with the JasperReports IO plugin can be done by using
Chrome/Chromium. The application auto-detects the Chrome/Chromium in the eight predefined locations.
If the application does not find Chrome/Chromium in these predefined locations, then point the application to
the location of the Chrome/Chromium by specifying the path to the chrome executable in
net.sf.jasperreports.chrome.executable.path property in the following file:
[JSS_INSTALL]/jrio/jrio/WEB-INF/classes/jasperreports.properties
• Subdataset – You can use a subdataset to provide a secondary record nested within a report. A subdataset
iterates through its data source records similar to a dataset. However, a dataset can use the same connection
that is used to fill the master report or it can use a different connection or data source. Subdatasets can be used
to iterate through data that is not the main report data source itself, for example, to gather data for a chart or
perform data bucketing for a crosstab.
Because dataset declarations can contain parameters, fields, variables, and groups, they closely resemble
subreports, but they completely lack any visual content (that is, they have no sections or layout information at
the dataset level).
Datasets, when instantiated, expect to receive parameter values and a data source to iterate through. As a
convenience, you can associate an SQL query with a dataset that uses a JDBC connection.
A dataset gives an abstract description of your record metadata but does not say where the data is coming from. For
example, you can create a dataset that stores the information that you have three fields – Last Name, First Name,
City – and that those fields are text fields.
When you create a subdataset, you can optionally choose a connection or data source to use as a resource to specify
your fields. For example, if you will ultimately be retrieving the records above from a JDBC database, you can use
the JDBC connection to retrieve the field information from your data, rather than entering it manually. However,
when you save the dataset it does not specify the data source, so, for example, you could later retrieve the field
values from the JDBC connection or you could retrieve them from a CSV file. The final binding of the subdataset
to its data retrieval method does not occur until you add an element to your report and define a dataset run.
Unlike other elements, a table and list always require a subdataset; they cannot use the main dataset.
When you create a dataset run, you can set the value of the subdataset parameters using expressions containing
main report objects (like fields, variables, and parameters), define a parameters map to set values for the subdataset
parameters at run time, and define the connection or data source that will be used by the subdataset.
14.2 Subdatasets
The Dataset page of the Dataset wizard shows the following options:
• Dataset name – A name for the subdataset. Must be unique in the report.
• Dataset radio buttons:
• Create new dataset from a connection or Data Source – Select this to use a connection or data
source to define the metadata for the dataset. The connection or data source will introspect its associated
data and suggest fields and field types for the dataset. Later, when you add an element and create a dataset
run, you make the final choice on where to retrieve the data for the element. At that point, you can use the
same data source/connection, or select a different one.
• Create an empty dataset – Select this to create a dataset without metadata. In this case, you will need
to define the metadata later, when you create a dataset run that uses this dataset.
• Next – Displays the Data Source page (only available when Create new dataset from a connection or
Data Source is selected).
You cannot use objects coming from the master report dataset directly in an element that uses a subdataset. Only
subdataset objects can be used in these cases. To use objects from your main report, you must declare them as
parameters in your subdataset. You configure the binding between the main dataset object with the subdataset
parameter inside the dataset definition, and then set the values for the parameters inside the dataset run.
For example, suppose you have a parameter named MyParam of type String in the main report and you want to
use it with a subdataset. Add it as a parameter to the subdataset by right-clicking the Parameters node in the
subdataset and selecting Create Parameter. Then in the Properties view for your new parameter, set the name as
MyParam, and the class as java.lang.String. To set the value that this parameter will have at runtime, define
an expression in the dataset run of the element that will use the parameter. Setting the expression for a parameter
inside the dataset run means that the parameter is evaluated when the element is evaluated. This means that when
you use a parameter in two different elements, one inside the title band and one inside the summary band, the
parameter's value can be different in the two different elements.
Option Description
• Filter Expression – Boolean expression that determines whether records that are read from the data source
should be used. Can use all the objects of the dataset (parameters, variables, and fields). Here are some
examples of filter expressions:
• Filter only records where the field FIRSTNAME starts with the letter “L”:
• JavaScript: $F{FIRSTNAME}.substr(0,1) == "L"
• Groovy: $F{FIRSTNAME}.startsWith("L")
• Filter only records where the length of the field FIRSTNAME is less than 5:
If the main report dataset uses a connection, such as a JDBC connection, you see the following options:
• Don't use any connection or Data Source – Select this if you do not want to specify any data for the
dataset run. You can set this if you have set a data adapter via properties view, and want JasperReports Library
to use that adapter. This setting can be used when you want to publish a report with multiple connections to
JasperReports Server.
• Use another connection – Select this and enter a connection expression to use a connection that is
different from the connection in the main dataset. You can use this for any connection, such as a JDBC
connection or big data connection.
• Use a JRDatasource expression – Select this and enter a data source expression if you want to use a data
source. Note that, even when the main report uses a data source, such as a CSV file or JSON data source, you
cannot simply reuse the data source from the main report. Instead, you must define a subdataset and create a
dataset run that accesses the data source. This is because, unlike a connection, a data source is consumed when
JasperReports iterates through it to fill the element. This means that when you use the same data source in two
different elements, you must access the data source twice.
• Use same JDBC connection used to fill the master report – If the report uses a connection, such as a
JDBC connection or a Hibernate connection, select this to have the dataset run use the same connection as the
main report. You can optionally enter a different query from the query in the main report.
When Use same JDBC connection used to fill the master report is selected, the connection
expression uses the built-in parameter for the report's JDBC connection, $P{REPORT_CONNECTION}.
• Use an empty Data Source – Select this to fill the dataset using an instance of JREmptyDataSource, that
is, a data source that contains a specified number of records, where the field values are all NULL. See 10.10,
“Using the Empty Record Data Adapter,” on page 183 for more information.
If the main report uses a data source, the menu and options are slightly different.
• Don't use connection or data source – Select this if you do not want to specify any data for the dataset
run
• Use a Connection expression – Select this to use any connection, such as a connection to a JDBC
database or a big data store.
• Use a DataSource expression – Select this to connect to a non-JDBC data source, for example, a JSON or
XML data source.
Create a report:
1. Create a basic report using a blank template, for example, Blank A4, and click Next.
2. Give your report a name, for example, DataSetReport, and click Next.
3. Choose Sample DB - Database JDBC Connection and click Next.
You can create a data adapter separately or click New... to create a data adapter directly from this dialog.
Adapters can be created globally (embedded in the workspace) or local to a specific project. Using a local
adapter makes it easier to deploy the report to JasperReports Server. See 10.1, “Creating and Editing
Data Adapters,” on page 144 for more information.
4. Enter the SQL query select count(*) as tot_orders from orders and click Next.
5. Add TOT_ORDERS as a field and click Finish. The report is displayed.
6. Drag the TOT_ORDERS field to the Detail band. If you want, you can remove all bands except the Title, Detail,
and Summary bands, and add a static text field to the title band to identify the report.
7. Preview the report.
The resulting main report has a single record containing the total number of orders.
Create a subdataset:
1. Right-click your report's root node in outline view.
2. Select Create Dataset from the context menu.
The Dataset wizard is displayed.
3. Enter a name for your dataset. For this tutorial, name it ExampleDataset.
4. For this tutorial, select Create new dataset from a connection or Data Source. This includes a data
adapter as part of your dataset definition.
If you select Create an empty dataset, your dataset does not include any data adapter or field information.
You will need to configure this information separately for each dataset run.
5. Click Next.
6. Select the data source you want for your dataset and click Next. For this example, select Sample DB.
3. In the dataset run section of the Chart Wizard, select the dataset you created, ExampleDataset.
4. Select Use same JDBC connection used to fill the master report from the dropdown menu. This
causes the expression to be set automatically to the connection used by the main report ($P{REPORT_
CONNECTION}).
5. To force the expression context to update the fields, parameters, and values after the dataset run configuration,
close the dialog, then reopen it by double-clicking the chart. If you do not force an update, you will not see the
correct fields in the expression editor.
6. Set the chart dataset expressions (the expressions used to fill the chart):
• Click … next to Series to open the Series dialog. Then select SERIES1 and click … to open the
expression editor and enter the following expression:
$F{SHIPCOUNTRY}
Click Finish, then click OK to return to the Chart Wizard. Note that the Key field below the chart
updates to show the same value as the series.
• Click … next to Value to open the expression editor. Enter the following expression:
$$F{COUNTRY_ORDERS}}
Click Finish to return to the Chart Wizard.
You cannot use objects from the master report dataset in a element that uses a subdataset. Only subdataset
objects can be used. To use an objects from the master report dataset, you must pass it as a variable or a
parameter.
A bursting scriptlet ensures it will create a scheduler job for each record in the data source with the required
parameters by calling the REST API of the JasperReports Server. The jobs are created automatically during the
report execution for each record in the data source.
The scriptlet uses a data adapter to create the connection for rest_V2/jobs when the report itself doesn't use a
JasperReports data adapter.
To burst a report:
1. Create a CSV file with two columns Country and Email, and create a data adapter that points to this CSV file.
2. Create a report containing two fields country $F(Country) and Email address of recipient $F(Email). This
report is a bursting report used for bursting operation.
3. A bursting scriptlet is required for the bursting report. To create a scriptlet, in the Outline view, right-click the
Scriptlets, and select Create Bursting Scriptlet. It will create a bursting scriptlet.
4. To edit the properties of the bursting scriptlet, right-click the bursting scriptlet and select Edit Bursting
Properties. Bursting scriptlet edit dialog will appear.
5. On the Parameters tab, click Add to add the parameter. Report Bursting Parameter dialog will appear. Enter
the Parameter name and Parameter value you want to pass to the burst reports. For example:
Parameter name: ShipCountry_1
Parameter value: $F{Country}
6. On the Options Configuration tab, select the Essential Options from the left panel and set the following fields:
Server profile: select the server connection from the drop-down for the bursting report. For example,
JasperReports Server Pro.
Enabled: true
Job Label: Sales By Country
Report URI: browse the repository and select the report you want to burst.
The path to the burst report in a bursting report is interpreted as relative to the user that runs the report. So if
the burst report is part of an organization, you will not be able to have a bursting report that works for both
superuser and users from that organization (jasperadmin and joeuser). superuser needs the absolute path
and users from the organization needs a relative path. It is recommended to run bursting reports that belong
to the same organization as the user.
Server data adapter: JasperReportsServerDataAdapater.jrdax. This data adapter makes the connection
to the JasperReports Server and lets you publish the reports to the server.
i. Click to enter the expression, Edit property value dialog will appear.
ii. Select Use Expression and click the expression editor.
b. In the Subject field, enter the subject for the mail to be sent to recipients.
c. In the Message field, type the message you want to send to recipients.
d. Click OK.
9. Run a bursting report.
Burst reports will be created in the output folder for different countries in both formats pdf and excel.
billing_address_street
billing_address_city
name
7. Click Next.
8. Group the fields by the element that triggers the report splitting. To do this, select the billing_address_
country field and click the right arrow.
14. Upload the report to JasperReports Server, you can see three tabs representing individual reports of Canada,
Mexico, and the USA in the report viewer.
15. Run the report in the scheduler. To do this, right-click the report and select Run in Background from the
context menu.
16. On the Output Options tab, set the output options and click Submit.
17. On the Notifications tab, enter the email address and subject of the email to be sent to each recipient.
Provide dynamic values in the following text fields To, CC, and Subject.
18. Select the Include report files as attachments option and click Submit.
A single report is split into three separate reports and sent to the email address of different recipients.
To create a tabular layout for a simple report with columns that resize together, you can use spreadsheet
layout. While not as complex as the Table component, you can use it directly in a report without defining a
dataset. See 4.9, “Working with Spreadsheet Layout,” on page 65 for more information.
cursor changes to show that an element is selected. Click and drag in the report editing area to size and
place the element. When you size the table when you first insert it, the columns fill the whole table.
Once you have placed your table in your report, use the Table Wizard to choose a new or existing dataset for your
table.
2. Name your dataset and select your option: Create new dataset from a connection or data source or
Create an empty dataset. For this example, choose the first option and click Next. You'll be prompted to
select a data source and design query.
3. Select a data source and enter an SQL query such as: select * from orders and click Next. You'll be
prompted to select dataset fields.
4. Select the fields you want in your table and add them to the Fields list on the right. Then click Next. You'll
be prompted to select the fields to group by from among your chosen fields.
5. Select one or more fields to group by and move them to the Fields list on the right. Click Next. You'll be
prompted to select a connection.
8. Select one or more fields to for table columns and move them to the Fields list on the right. Click Next. You'll
be prompted to select a layout.
9. Select the layout for your table, and click Finish. The table appears where you dragged the table element in
your report.
To edit a style in the palette, double-click the style and edit it in the Layout window. You can save it either as a
new style or with the same name. To a edit table layout in the Design tab, right-click the table and choose Change
Table Style.
You can also decide which table sections to create. If the dataset for the table contains groups, it can be convenient
to select the Add Group Headers and Add Group Footers check boxes.
To delete a style right click it in the Table Styles tab and choose Delete Style.
• To edit the content and style of a cell, click the cell. Switch to the Properties view where you can edit
location, size, color, style, and print details for the cell.
• To edit the size and position of a cell, or copy or delete it, right-click on the cell and select an action from the
context menu.
Here you can set the dataset parameters to dynamically filter the data used in the table.
Suppose, for instance, you have a report that displays order details in a table, you can use a parameter in your SQL
query to specify the order ID to filter the order details.
Unlike charts and crosstabs, a table always requires a subdataset. Tables cannot use the main dataset.
Each table is divided into sections similar to the main document bands:
• Table header and footer - each printed only once.
• Column header and footer - repeated on each page the table spans. For column groups, the table can display
a group header and footer section for each group and for each column.
• Detail - repeated for each record of the table. Each column contains only one detail section, and the section
cannot span multiple columns.
In the Outline view, table sections are shown as child nodes of the table element node.
In the Design tab, each column has a cell for each section (for example, one cell for the table header section,
another for the table footer, etc.). A cell can be undefined. If all the cells of a section are undefined, the section is
not printed. If the height of all the cells of a section is zero, the section is printed but is not visible in the Design
tab.
• You can set cell padding as well as borders from the Properties > Borders tab.
• Cell height defines the vertical dimension of a cell. When its value is changed, the new dimension is
propagated to all the cells in the row.
• Table cells are containers that can include other elements. To set a layout for the cell contents, click in the
column header or footer and select Arrange in Container from the action menu, then select a layout option. See
4.2.4, “Positioning Elements in Containers,” on page 49
• You can drag a column to any position, inside or outside a group. Move a column within the same section by
dragging the nodes that represent the columns in outline view.
A column group acts as a single unit when you drag it. If you drag the last column out of a column group, the
column becomes a simple column and the remaining group cells are deleted.
When you create a column group, every column section gets a group heading, as shown in Figure 16-22, but you
can remove unnecessary headings. On the left of the figure there are two columns (most of the sections in the
columns have only one record; one section has two records). When the columns are grouped, each column section
gets a group heading, as shown in the center. However, most of the group headings are unnecessary, so their
heights have been set to zero to hide them, as shown on the right.
5. Drag the Chart tool from the Palette into the Summary band. The Chart Wizard opens.
In the Design tab, the chart is a placeholder and doesn't display your data.
To configure a chart:
1. Double click the chart. The Chart Data Configuration window opens.
The Chart Data tab shows the fields within the specified dataset. You'll find detailed descriptions of field
types and their functionality in the JasperReports Library Ultimate Guide.
3. Set 10 for Max slices to show. For a chart of many slices, this field specifies the number to show. A chart
slice labeled Other contains the slices not shown.
4. On the Dataset tab, you can define the dataset within the context of the report.
You can use the Reset on controls to periodically reset the dataset. This is useful, for example, when
summarizing data relative to a special grouping. Use the Increment on control to specify the events that
trigger addition of new values to the dataset. By default, each record of the chart's dataset corresponds to a
value printed in the chart. You can change this behavior and force the engine to collect data at a specific time
(for instance, every time the end of a group is reached).
Set Reset on to Report since you don’t want the data to be reset, and leave Increment Type set to None
so that each record is appended to your dataset.
5. Also in the Chart Data Configuration dialog, enter an expression to associate with each value in the data
source. For a Pie 3D chart, three expressions can be entered: key, value, and label.
• Key expression identifies a slice of the chart. Each key expression must be a unique. Any repeated key
simply overwrites the duplicate key. A key can never be null.
• Value expression specifies the numeric value of the key.
• Label expression specifies the label of a pie chart slice. This is the key expression by default.
Next to each field, click the button. Enter the following:
Value: $F{orders}
Label: $F{shipcountry}
Key: $F{shipcountry}
6. Click Finish.
7. Save your report, and preview it to see the result.
In this chart, each slice represents a country and the shipping total for that country.
For more information about setting hyperlinks, see “Anchors, Bookmarks, and Hyperlinks” on page 72.
JasperReports Server takes advantage of only a small portion of the capabilities of the JFreeChart library. To
customize a graph, you must write a class that implements the following interface:
net.sf.jasperreports.engine.JRChartCustomizer
It takes a JFreeChart object and a JRChart object as its arguments. The first object is used to actually produce
the image, while the second contains all the features you specify during the design phase that are relevant to the
customize method.
4. Drag a Static Text element into the title bar, and name your report something like “Employee Orders by
Month and Country”.
5. Enlarge the Summary band to 350 pixels by changing the Height entry in the Band Properties view.
2. Select the report in the Outline view, and in the Properties view, click the Edit query, filter, and sort
options button. The Dataset and Query dialog opens.
To filter your data in a Spider Chart, you must filter it in the Dataset and Query dialog.
3. To filter data for a more readable chart, click the Increment Expression tab and enter the expression below
with no manual line breaks, then click OK.
( $F{shipcountry}.startsWith("N") || $F{shipcountry}.startsWith("M") || $F
{shipcountry}.startsWith ("U") || $F{shipcountry}.startsWith ("I") ) || $F
{shipcountry}.startsWith("A") && ( $F{shipname}.startsWith( "M" ) || $F
{shipname}.startsWith( "A" ) || $F{shipname}.startsWith( "G" ) )
4. Double-click the chart to display the Chart Data Configuration dialog.
5. Click the Series button and create the series $F{employeeid}.
6. Click the Value button and create the value MONTH($F{orderdate}).
7. Click the Category button and create the category $F{shipcountry}.
8. Click Finish.
2. Enter or select the parent folder, name the file, and name your theme. Click OK.
A dialog indicates that the Chart Theme was generated.
5. Fill in the properties as prompted by the user interface. For example, the following values for Legend Shape
change the legend to an circle:
• Apply to – All Items
• Shape Type – Ellipse
• Width – 10
• Height – 10
6. Click Finish.
The customizer selection dialog box is closed and the customizer is applied to your chart. Click Preview to
view your chart.
3. In the Advanced tab of Properties view, click … next to Common Chart Properties> Customizer Class.
The Open Type dialog is displayed.
4. Enter the name of your class in the Open Type dialog and click OK.
A chart customizer defines a customize method that takes a JFreeChart object and a JRChart object. The
customize method can access chart settings and make changes to them. During report execution, JasperReports
calls the customize method for the chart and applies the settings, along with the settings from the JSON file.
RangeAxisCustomizerSample is as shown below.
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.XYPlot;
import net.sf.jasperreports.customizers.axis.AbstractAxisCustomizer;
import net.sf.jasperreports.engine.JRChart;
/**
* Customizer to define the minimum and maximum value of the domain axis, works for
* XY plot
*/
public class RangeAxisCustomizerSample extends AbstractAxisCustomizer
{
@Override
public void customize(JFreeChart jfc, JRChart jrc)
{
ValueAxis valueAxis = null;
if (valueAxis != null)
{
configValueAxis(valueAxis, PROPERTY_MIN_VALUE, PROPERTY_MAX_VALUE);
{
"label": "Range Axis Range and Tick - Sample",
"description": "Customizer to set the range for the axes and the tick spacing for an axis
chart.",
"customizerClass": "com.jaspersoft.studio.sample.customizer.RangeAxisCustomizerSample",
"supportedPlot": ["13","14","15"],
"sections": [
{
"name": "Customizer configuration",
"expandable": false,
"properties": [
{
"name": "minValue",
"label": "Range Min",
"description": "The minimum value on the axis",
"mandatory": false,
"readOnly": false,
"type": "double"
},
{
"name": "maxValue",
"label": "Range Max",
"description": "The maximum value on the axis",
"mandatory": false,
"readOnly": false,
"type": "double"
},
{
"name": "tickUnit",
"label": "Distance",
"description": "The space between ticks.",
"mandatory": false,
"defaultValue": "1",
"readOnly": false,
"type": "double"
}
]
}
]
}
CHART_TYPE_AREA 1
CHART_TYPE_BAR3D 2
CHART_TYPE_BAR 3
CHART_TYPE_BUBBLE 4
CHART_TYPE_CANDLESTICK 5
CHART_TYPE_HIGHLOW 6
CHART_TYPE_LINE 7
CHART_TYPE_PIE3D 8
CHART_TYPE_PIE 9
CHART_TYPE_SCATTER 10
CHART_TYPE_STACKEDBAR3D 11
CHART_TYPE_STACKEDBAR 12
CHART_TYPE_XYAREA 13
CHART_TYPE_XYBAR 14
CHART_TYPE_XYLINE 15
CHART_TYPE_TIMESERIES 16
CHART_TYPE_METER 17
CHART_TYPE_THERMOMETER 18
CHART_TYPE_MULTI_AXIS 19
CHART_TYPE_STACKEDAREA 20
CHART_TYPE_GANTT 21
• sections – Property that controls the display of the user interface. Has the following attributes:
• name – Name for the user interface dialog box.
• expandable – Boolean; for chart customizers, always set to false.
• properties – Attribute that contains sections to define each entry box in the user interface. Each entry
box has the following attributes:
• name – Name of the argument to pass to the customizer class.
• label – Name that appears in the user interface.
• description – Tooltip that appears on hover.
• mandatory – Boolean. When true, the property is required; when false, property is optional.
• readOnly – Sets attribute as read-only. Not used for chart customizers.
• type – Type of the attribute, as expected by the customizer class.
• defaultValue (optional) – Default value for an optional property.
To add a non-configurable customizer, use an empty list for the properties. For example:
"sections": [
{
"name": "Customizer configuration",
"expandable": false,
"properties": []
}
]
This section describes functionality that can be restricted by the software license for Jaspersoft Studio. If you
don’t see some of the options described in this section, your license may prohibit you from using them. To find
out what you're licensed to use, or to upgrade your license, contact Jaspersoft.
The HTML5 Chart Edit dialog has two configuration views: simple and advanced.
• Simple view lets you quickly configure your categories, measure, and series contributor
• Advanced view gives you more control and access to advanced features.
You can also preview a chart from the chart dialog by clicking in the HTML5 Chart Edit dialog.
This chapter has the following sections:
• Overview of HTML5 Charts
• Example of a Bar Chart Using Simple Configuration
• Example of a Pie Chart
• Example of a Tile Map Chart
• Example of a Time-Series Spline Chart
• Example of a Tree Map Using Multiple Levels and Advanced Formatting
• Example of a Scatter Chart Using Advanced Configuration
• Example of a Column-Spline Chart
• Creating Hyperlinks in HTML5 Charts
• Advanced Formatting of HTML5 Charts
• Setting Advanced Options for HTML5 Charts in Properties View
• Master-detail Chart
For details about charts implemented through JFreeCharts, see “Working with Charts” on page 299.
In HTML5 Charts Jaspersoft Studio are similar to Ad Hoc charts in JasperReports Server.
Before you add a chart to your report, consider the best way to display your data. The following table describes the
available chart types.
Icon Description
Bar. Graphically summarize and display categories of data to let users easily compare
amounts or values among categories.
Icon Description
Stacked Bar. Multiple measures of a group are depicted as portions of a single bar whose
size reflects the aggregate value of the group.
Percent Bar. Multiple measures of a group are depicted as portions of a single bar of fixed
size representing 100% of the amounts for a category. Used when you have three or more
data series and want to compare distributions within categories and at the same time
display the differences between categories.
Line. Displays data points connected with straight lines, typically to show trends.
Spline. Displays data points connected with a fitted curve. Allow you to take a limited set
of known data points and approximate intervening values.
Stacked Line. Displays series as a set of points connected by a line. Values are
represented on the y-axis and categories are displayed on the x-axis. Lines do not overlap
because they are cumulative at each point.
Stacked Spline. Displays series as a set of points connected with a fitted curve. Values
are represented on the y-axis and categories are displayed on the x-axis. Lines do not
overlap because they are cumulative at each point
Stacked Percent Line. A variation of a line chart in which each series adjoins but does
not overlap the preceding series.
Stacked Percent Spline. A variation of a spline chart in which each series adjoins but
does not overlap the preceding series.
Icon Description
Area charts - Compare values displayed as shaded areas. Compared to line charts, area charts emphasize
quantities rather than trends.
Area. Displays data points connected with a straight line and a color below the line; groups
are displayed as transparent overlays.
Stacked Area. Displays data points connected with a straight line and a solid color below
the line; groups are displayed as solid areas arranged vertically, one on top of another.
Stacked Percent Area. Displays data points connected with a straight line and a solid
color below the line; groups are displayed as portions of an area of fixed sized, and
arranged vertically one on top of the another.
Area Spline. Displays data points connected with a fitted curve and a color below the line;
groups are displayed as transparent overlays.
Stacked Area Spline. Displays a series as a set of points connected by a smooth line with
the area below the line filled in. Values are represented on the y-axis and categories are
displayed on the x-axis. Areas do not overlap because they are cumulative at each point.
Stacked Percent Area Spline. A variation of area spline charts that present values as
trends for percentages, totaling 100% for each category.
Icon Description
Dual-Level Pie. A variation of pie charts that present grouped values in two concentric
circles; the inner circle represents the coarsest grouping level in the data. In Jaspersoft
Studio, note these rules about data configuration for dual-level pie charts:
• Only one measure is displayed (the first)
• The last row level is rendered as the outer pie
• The next to last row level is rendered as the inner pie; if only one row level is defined,
the inner pie consists of a single section representing the total
Scatter and Bubble Charts - Show the extent of correlation, if any, between the values of observed
quantities.
Scatter. Displays a single point for each point in a data series without connecting the
points.
Bubble. Compares the relationships between three measures displayed on the x-y axis.
The location and size of each bubble indicates the relative values of each data point
Multi-Axis Charts - Compare trends in two or more data sets whose numeric range differ greatly.
Multi-Axis Column. A column chart with two series and two axis ranges.
Multi-Axis Line. A line chart with two series and two axis ranges.
Multi-Axis Spline. A spline chart with two series and two axis ranges.
Icon Description
Combination Charts - Display multiple data series in a single chart, combining the features of a area, bar,
column, or line charts.
Column Line. Combines the features of a column chart with a line chart.
Column Spline. Combines the features of a column chart with a spline chart.
Stacked Column Line. Combines the features of a stacked column chart with a line chart.
Stacked Column Spline. Combines the features of a stacked column chart with a line
chart.
Time Series Charts - Illustrate data points at successive time intervals. Also called Fever Chart.
Time Series Area. Displays data points over time connected with a straight line and a
color below the line.
Time Series Area Spline. Displays data points over time connected with a fitted curve
and a color below the line.
Time Series Line. Displays data points over time connected with straight lines.
Icon Description
Time Series Spline. Displays data points over time connected with a fitted curve.
Spider Charts - Display data in line or data bars arranged on a circular spider web chart. Also called a
Radar Chart.
Spider Column. Plots one or more series over multiple common quantitative variables by
providing axes for each variable arranged as spokes around a central point. The column
variation of spider charts displays values as bars that extend out from the central point
towards the edges of the circular web. The bar's length indicates the relative value.
Spider Line. Plots one or more series over multiple common quantitative variables by
providing axes for each variable arranged as spokes around a central point. The line
variation of spider charts displays values as points arranged around the circular web. The
data points are joined by a line. Each point's distance from the central point indicates the
relative value.
Spider Area. Plots one or more series over multiple common quantitative variables by
providing axes for each variable arranged as spokes around a central point. The area
variation of spider charts is similar to the line variation, but the shape defined by the line
that connects each series' points is filled with color.
Range Charts
Heat Map. Represents data in a matrix format, using color coding to show values.
Time Series Heat Map. Represents data across time in a heat map, using color coding to
show values.
Dual Measure Tree Map. Displays data as color-coded rectangles; the size of each rect-
angle is proportional to the first measure and the color represents the second measure.
Icon Description
Tree Map. Displays data as rectangles; the size of each rectangle is proportional to the
measure of the data it represents. The tree map displays nested rectangles when you
have more than one field; the parent rectangle represents the leftmost measure while the
nested rectangles represent the current level of aggregation. Click on a parent rectangle to
drill down to the nest rectangles
One Parent Tree Map. Displays data as nested rectangles; the size of each rectangle is
proportional to the measure of the data it represents. The nested rectangles represent the
current level of aggregation while the larger rectangle represents the parent level in the
hierarchy. Click on a parent rectangle to drill down to the nest rectangles.
Tile Map. Displays data in the form of tiles aligned on a grid to create a pattern. The
related data measure is displayed on each tile.
Gauge Charts
Gauge. Displays a single data value as a portion of a circle; the length of the circle is the
data's numeric value proportional to the maximum size defined for the measure.
• One or more Measures required in the Columns location.
• One or more Fields required in the Columns location.
• Define the minimum and maximum sizes, color stops, and layout on the Appearance
tab.
Multi-level Gauge. Displays one or more data values as concentric circles; each circle
represents a measure and the length of the circle is the data's numeric value proportional
to the maximum size defined for the measures.
• Two or more Measures required in the Columns location.
• One or more Fields required in the Columns location.
• Define the minimum and maximum sizes, color stops, and layout on the Appearance
tab.
Arc Gauge. Displays a single data value as a portion of a semi-circular arc; the length of
the arc is the data's value proportional to the maximum size defined for the measure.
• One or more Measures required in the Columns location.
• One or more Fields required in the Rows location.
• Define the minimum and maximum sizes, color stops, and layout on the Appearance
tab.
measures.
Before you add a chart, consider the best way to display your data. Available chart types are listed in Table 18-1.
This example contains the following sections:
• Creating an HTML5 Chart
• Adding a Measure to a Bar Chart
• Formatting a Chart
• Creating a Hyperlink
A panel similar to the one in this section is used for the following chart types: Bar, Column, Line, Area, Spline,
AreaSpline, StackedBar, StackedColumn, StackedLine, StackedArea, StackedSpline, StackedAreaSpline,
StackedPercentBar, StackedPercentColumn, StackedPercentLine, StackedPercentArea,
StackedPercentSpline, StackedPercentAreaSpline, SpiderColumn, SpiderLine, SpiderArea.
1. Click HTML5 Charts in the Components Pro section of the Palette. The cursor changes to to show
that an element is selected. Click and drag in the Summary band to size and place the chart.
The HTML5 Chart Edit Dialog is displayed.
2. Select a chart type based on the information you want to display. See “HTML5 Chart Types” on page 318
for help. You can use the menu at the left to restrict the selection to a particular type of chart. For this
example, choose Bar.
3. Click the Data Configuration tab. This tab includes options for configuring chart dataset, chart properties, and
hyperlinks. The options on this tab reflect the type of chart you selected.
4. Enter the expression you want to use for the categories. You can enter the expression directly, or click to
open the Expression Editor. For this example, enter the following:
• Category Expression – $F{SHIPCOUNTRY}.
5. Enter the information you want for the series:
• Series – This menu displays the default name of the series, for example, Series 1. If you want to change
the name, use advanced configuration.
• Value Expression – Enter the expression you want to use as a base for the measure calculation. For this
example, use $F{Freight}.
• Aggregation Function – Select the function to apply to the value expression. For this example, use
Average.
• Tooltip Expression – Enter an expression to display as a label for the measure. For this example, enter
"Average Freight".
6. To preview the chart from inside the dialog box, click Show Chart Preview.
A preview is displayed in the right of the dialog. This preview can take some time to load the first time it is
run.
11. Save, then click the Preview tab to see your chart. To see an interactive preview, select HTML from the
Preview drop-down. Hover over a bar to see the average freight.
The preview works best when you are using the same dataset as the main report. Parameters may not be
applied and multiple levels or series may not display.
You can set additional options using the Show Advanced Properties button. See 18.10, “Advanced
Formatting of HTML5 Charts,” on page 367 for more information.
You can set JasperReport element properties for an HTML5 chart, such as position or evaluation time, in
Properties view. See 18.11, “Setting Advanced Options for HTML5 Charts in Properties View,” on
page 369 for more information.
5. Expand Legend, select Legend > Sizes and Position, and set the location of the legend on the graph:
• Horizontal Alignment – right.
• Vertical Alignment – middle.
• X offset – -6. This moves the legend inside the plot background color.
6. Select Legend > Items and set the following:
• Items Layout – vertical.
Click OK.
4. Click the color wheel next to Plot Background Color and select a color. For this example, enter #FFFACD.
This sets the background color of the plot area only.
5. Click OK.
6. Save and preview your report.
A panel similar to the one in this section is used for the following chart types: Pie, SemiPie.
1. Click HTML5 Charts in the Components Pro section of the Palette. The cursor changes to to show
that an element is selected. Click and drag in the Summary band to size and place the chart.
The HTML5 Chart Edit Dialog is displayed.
1. Create a new report using the Sample DB data adapter.
2. Start with the query:
select * from orders
3. Choose HTML5 Charts from the Components Pro section of the Palette, and drag it into the
Summary band of your report.
The HTML5 Chart Edit Dialog is displayed.
4. Select a chart type based on the information you want to display. You can use the menu at the left to restrict
the selection to a particular type of chart. For this example, choose Pie.
5. Click the Data Configuration tab. This tab includes options for configuring chart dataset, chart properties, and
hyperlinks. The options on this tab reflect the type of chart you selected. The dialog shown in this example is
used for pie and semi-pie charts.
6. Enter the required information on the Data sub-tab. For this example:
• Slice Expression – Enter the expression you want to use for the slices. You can enter the expression
directly, or click to open the Expression Editor. For this example, use $F{SHIPCOUNTRY}.
• Value Expression – Enter the expression you want to use as a base for the measure calculation. For this
example, use $F{ORDERID}.
• Aggregation Function – Select the function to apply to the value expression. For this example, use
DistinctCount.
• Tooltip Expression – Enter an expression to display when a user hovers over a slice of the pie. For this
example, enter "Orders".
• Ordering – Select an order for the slices. For this example, choose Ascending. This displays the slices
in alphabetical order.
7. To preview the chart from inside the dialog box, click Show Chart Preview.
A preview is displayed to the right of the dialog. This preview can take some time to load the first time it is
run.
8. Click the Dataset sub-tab. This sub-tab lets you choose a dataset and dataset properties. For this example, use
the default [Report main dataset].
9. You can optionally filter the dataset by entering an expression in the Increment expression text box. You
can enter text directly or click to open the Expression Editor. For this example, filter your dataset using the
following increment expression:
$F{SHIPCOUNTRY}.startsWith("I") ||
$F{SHIPCOUNTRY}.startsWith ("S") ||
$F{SHIPCOUNTRY}.startsWith ("U")
1. Click HTML5 Charts in the Components Pro section of the Palette. The cursor changes to to show
that an element is selected. Click and drag in the Summary band to size and place the chart. The HTML5 Chart
Edit Dialog appears.
2. Select a chart type based on the information you want to display. You can use the menu on the left to restrict
the selection to a particular type of chart. For this example, choose TileMap.
3. On the Data Configuration tab of the HTML5 Chart Edit dialog, click Switch to advanced configuration.
4. Under Categories Levels, select Level1 and click Modify. Then enter the following:
• Expression: $F{y}
• Value Class Name: java.lang.Integer
Click OK.
5. Under Series Level, select Series1 and click Modify. Then enter the following:
• Expression: $F{x}
• Value Class Name: java.lang.Integer
Click OK.
6. Under Measures, select Measure1 and click Modify. Then enter the following:
• Value Expression: $F{population}
• Value Class Name: java.lang.Integer
Click OK.
You can optionally add other hidden measures, for example:
• for $F{hc_a2} - Value Expression: $F{hc_a2} and Value Class Name: java.lang.String.
• for $F{name} - Value Expression: $F{name} and Value Class Name: java.lang.String.
7. Click the Chart Formatting tab, select Chart > Title on the left and enter your title in the Title text box. For
this example, enter US states by population in 2016.
8. Select Subtitle and enter Subtitle in the Subtitle text box. For this example, enter Source: Wikipedia.
9. On the Chart Formatting tab, select Tilemap on the left. You can set two additional properties of the tilemap
chart: Tile Shape and Color By Point.
10. Select the tile shape from the drop-down. For this example, Tile Shape is Hexagon and Color By Point is set to
false.
The default tile shape is Hexagon, you can also select Circle, Diamond, or Square. If Color By Point is set to true,
any tile in the chart is colored with consecutive colors in the 'Colors' chart property. The Color By Point property
can be neglected when colors are defined in the colorAxis property.
13. On the Item list tab, click to add an item. A new item is created with the name Item 1 and enter the follwing
information.
• colorAxis.dataClasses.color: #F9EDB3
• colorAxis.dataClasses.name: <1M
• colorAxis.dataClasses.to: 1000000
14. To add a second item, click and enter the follwing information.
• colorAxis.dataClasses.color: #FFC428
• colorAxis.dataClasses.from: 1000000
• colorAxis.dataClasses.name: 1M-5M
• colorAxis.dataClasses.to: 5000000
Click OK.
15. To enable the labels to appear in each tile map, select plotOptions > tilemap > dataLables and set enabled
to true.
16. To preview the chart from inside the dialog, click Show Chart Preview.
The following chart types use a similar interface: TimeSeriesLine, TimeSeriesSpline, TimeSeriesArea,
TimeSeriesAreaSpline.
1. Click HTML5 Charts on the Components Pro section of the Palette. The cursor changes to an
element is selected. Drag to fill the Summary band of your report.
The HTML5 Chart Edit Dialog is displayed.
2. Select TimeSeriesSpline for your chart type.
3. Click the Data Configuration tab.
4. Enter an expression for the date in the Date Expression field. You can click to use the expression editor
or enter the expression manually. For this example, enter :
$F{ORDERDATE}.
5. To use multiple series, select Define your series manually.
6. Define your first series. For this example, use the following data:
• Series – Series 1. The name of the series is automatically generated. You can't change it in the simple
configuration.
• Value Expression – $F{FREIGHT}.
• Aggregation Function – Highest
• Tooltip Expression – "max freight"
7. To define an additional series, click . For this example, define a second measure using the following data.
• Series – Series 2.
• Value Expression – $F{FREIGHT}.multiply(new BigDecimal(0.5))
18.6 Example of a Tree Map Using Multiple Levels and Advanced Formatting
A tree map shows hierarchical data as nested rectangles. The size of each rectangle is proportional to the measure
of the data it represents. Users can click on a parent rectangle to drill through to the nest rectangles. Tree maps are
a compact way of showing tree data and can help you see patterns in your data that are difficult to see in other
ways.
This example shows a tree map for three levels of data: country, region, and city. The dialog shown is this example
is used for TreeMap and OneParentTreeMap.
1. Click HTML5 Charts in the Components Pro section of the Palette. The cursor changes to show
that an element is selected. Click and drag in the Summary band to size and place the chart.
Figure 18-20 Tree Map After Drill Through, Showing Formatting Issues
• When a country, such as USA, is selected, the adjacent country is shown on the chart.
• The label to return to a higher level reads undefined.
You can use advanced formatting to set these properties. For more information about advanced formatting, see
18.10, “Advanced Formatting of HTML5 Charts,” on page 367
3. Click Add.
4. The Chart Property dialog is displayed.
5. To prevent the names of other countries from showing on the border of the charts, enter the following, then
click OK:
• Property name – plotOptions.treemap.dataLabels.overflow
• Property value – none
6. To change the text of the button, click Add, enter the following, then click OK:
• Property name – plotOptions.treemap.drillUpButton.text
• Property value – Back
7. Click OK to apply your properties and return to Design view.
Preview the chart in HTML to drill through and see your changes.
Figure 18-23 Tree map after formatting issues have been corrected
Static Highcharts properties are always recognized as String. If you have problems setting a static Boolean
or numeric property, set it as an expression. For example, to set
plotOptions.series.dataLabels.enabled to false, use the following JRXML:
<hc:chartPropertyname="plotOptions.series.dataLabels.enabled">
<hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
</hc:chartProperty>
6. Under Categories Levels, select Level1 and click Modify. Then enter the following:
• Name: ShipCountry
• Expression: $F{SHIPCOUNTRY}
• Value Class Name: java.lang.String
• Order: Ascending
Click OK.
7. Under Categories Levels, click Add and create a second Category with the following information:
• Name: ShipCity
• Expression: $F{SHIPCITY}
• Value Class Name: java.lang.String
• Order: Ascending
Click OK.
8. Under Series Level, select Series1 and click Modify. Then enter the following:
• Name: Order Year
• Expression: YEAR($F{ORDERDATE})
• Value Class Name: java.lang.Integer
• Order: Ascending
Click OK.
9. Under Measures, select Measure1 and click Modify. Then enter the following for maximum freight:
• Name: Max Freight
• Label Expression: "Max Freight"
• Calculation: Highest
• Value Expression: $F{FREIGHT}
• Value Class Name: java.math.BigDecimal
Click OK.
10. Under Measures, select Measure0 and click Modify. Then enter the following for average freight:
• Name: Average Freight
• Label Expression: "Average Freight"
• Calculation: Average
• Value Expression: $F{FREIGHT}
• Value Class Name: java.math.BigDecimal
Click OK.
The chart is now configured. Click OK to close the dialog, then preview the chart.
The following chart types use this dialog: ColumnLine, ColumnSpline, StackedColumnLine,
StackedColumnSpline, MultiAxisLine, MultiAxisSpline, MultiAxisColumn.
1. Click HTML5 Charts in the Components Pro section of the Palette. The cursor changes to show
that an element is selected. Click and drag in the Summary band to size and place the chart.
2. In the HTML5 Chart Edit dialog, select ColumnSpline. If you are prompted to confirm, click Yes.
3. Click the Data Configuration tab.
The HTML5 Chart Edit dialog is displayed.
8. Save and preview your report. It should look like the following figure.
The supported constant values for series property type are column, line, and spline.
4. Preview your chart as HTML or using the interactive report viewer. Click any column to verify it points to the
Ask.com search for that country.
5. Click OK twice.
Once again, you can preview the chart. Now, for each country, the chart shows the number of orders split by
year.
Figure 18-39 Defining the URL to Open when the Measure is Clicked
about the number represented by the bar itself. This mechanism is a way to move from one report unit to another,
realizing what is more generally called drill-down and drill-up.
The execution of report units can be done by using hyperlink of type ReportExecution. This type requires to define
a hyperlink parameter called “_report”, which holds the location of the report unit inside the JasperReports server
repository.
Other hyperlink parameters can be defined to set values for input controls exposed by the report unit.
The next tutorial shows how to create a link to the report unit 04. Product Results by Store Type Report”, located at
/public/Samples/Reports/4_Product_Results_by_Store_Type_Report.
When executed, this report can be filtered by country, anyway, since this report unit does not expose through input
controls defined at report unit the country parameter, we cannot pass the country value we have.
1. Create a new report, following the steps described at the beginning of 18.9, “Creating Hyperlinks in HTML5
Charts,” on page 359
2. Modify the # of orders measure by adding the following properties in the advanced properties tab:
a. hyperlinkType (contributor: SeriesItemHyperlink, Static value: ReportExecution)
b. hyperlinkTarget (contributor: SeriesItemHyperlink, Static value: Blank)
c. 3_report (contributor: SeriesItemHyperlink, Static value: /public/Samples/Reports/4_Product_Results_by_
Store_Type_Report)
3. Publish the report in JasperReports Server and preview it on the web. Click a bar column to open the report
units we defined in the previous step.
Note that there is no special syntax to define a parameter, just use the name of the parameter as the property name,
and select the value (static, bucket or measure based).
The report unit 06. Profit Detail Report (/public/Samples/Reports/ProfitDetailReport) is a good candidate for this
test. It exposes the parameter ProductFamily, so by adding the ProductFamily hyperlink property, and by setting it
to a value like Drink, can pre-filter its results.
You can set a subset of properties for an Ad Hoc chart in Jaspersoft Studio, using the Chart Properties >
AdHoc Overrides section. However, this is not recommended. If you are working with Ad Hoc charts in
JasperReports Server, set your chart properties on the server, using the Advanced Properties tab in the
Chart Formatting dialog box. For more information about setting properties for Ad Hoc charts in
JasperReports Server, see Advanced Chart Formatting on the community website.
For a list of available properties, see the Highcharts website. Note that some cases, user-defined properties
may not be compatible with Jaspersoft Studio.
1. Click Add in the advanced view of the Chart Formatting tab in the HTML Chart Edit dialog.
Gradient property:
• Name – chart.backgroundColor.linearGradient
This setting is nested below the chart and background color settings.
• Use an expression – true
• Property value – java.util.Arrays.asList(0,0,500,500)
All settings must be cast to a Java data type, either explicitly or implicitly. The gradient setting takes an array
as a parameter and therefore must explicitly be returned as a list, using the static
java.util.Arrays.asList method.
Stops property:
• Name – chart.backgroundColor.stops
This setting requires an array of arrays and is expressed through the nested use of java.util.Arrays.
• Use an expression – true
• Property value:
java.util.Arrays.asList
(
java.util.Arrays.asList(0, "#b5bdc8"),
java.util.Arrays.asList(0.36, "#828c95"),
java.util.Arrays.asList(1, "#28343b")
)
Figure 18-44 Chart with a gradient background, set via user-defined properties
3. Expand the Misc section and click ... next to Edit Properties.
The Properties dialog opens.
4. Click Add to add a new property.
5. Enter the following information:
• Name: com.jaspersoft.jasperreports.highcharts.interactive
• Value: false
6. Click OK and then click Finish.
Like many advanced charting options, this option can be set at a higher level. If you set an option at multiple
levels, the lowest level is the one that is applied.
• To disable this option for a report, click on the report's root node in Outline view and make sure the Properties
view is displayed. In the Properties view, on the tab, select Advanced > Misc > Properties and click ... to
open the Properties Dialog. Enter the values shown above and click OK twice to apply the setting.
• To disable this option Jaspersoft Studio, select Window > Preferences from the menu (Eclipse >
Preferences on Mac). In the Preferences dialog box, select Properties and click Add to open the
Properties Dialog. Enter the values shown above and click OK twice to apply the setting.
You can also set this particular option in JasperReports Server. See the JasperReports Server Administrator Guide
for more information.
7. To define an additional measure, click Add. For this example, define a second measure using the following
data.
• Name – "Measure2"
• Label Expression – "Series 2"
• Value Expression – $F{FREIGHT}
• Value Class Name – java.lang.Number
Click OK.
8. Add a third measure with the following data:
• Name – "Measure3"
• Label Expression – "Series 3"
• Value Expression – $F{FREIGHT}/3.0 + ($F{OrderID}-10000)/10.0
• Value Class Name – java.lang.Number
Click OK.
9. On the Chart Formatting tab, select Colors Palette and add colors for the three measures. You can set the
colors manually or from the existing options.
Unlike HTML output, other output formats like PDF, PPTX, Excel etc., display only the master chart because
there is no interactivity in these formats.
You can increase the complexity of a crosstab by adding more row or column groups, or by using another summary
function, such as sum, average, or percent. For example, the following crosstab shows the sum of the monthly cost
of food for each pet (measure) by gender (column) and group and species (rows). Note that when there are multiple
row or column groups in a crosstab, they are displayed hierarchically.
Figure 19-2 Example of a crosstab with multiple row groups and a sum
Crosstabs in JasperReports support row and column groups, totals and subtotals, and individual cell formatting.
Data to fill the crosstab can come from the main report dataset or from a subdataset.
This chapter has the following sections:
• Example of Creating a Crosstab
• Working with Crosstab Properties
• Using the Crosstab Editor
• Working with Crosstab Parameters
4. For this example, make sure that Create a Crosstab using an existing dataset is selected, and select
[Main Dataset] from the drop-down menu.
5. Click Next. The Columns screen is displayed.
6. Enter one or more fields you want as column groups. For this example, choose the ORDERDATE field.
7. Select the ORDERDATE field. Then click on the Unique value in the Calculation column and select Year from
the drop-down menu. This aggregates the orders by year.
When you have a time field in your crosstab, you can use the Unique aggregation function to group records
having the same value, or you can aggregate it any of the following ways:
• Using a time-based aggregation function (such as Year, Month, Week, or Day) when you define the
group
In this example, this is shown in the previous step.
• Using a dataset query when you create the crosstab.
In this example, in the first step of the wizard, you could create a dataset that uses a query that returns
the year, such as select ORDERDATE, SHIPVIA, SHIPPOSTALCODE, SHIPCOUNTRY,
SHIPPEDDATE, YEAR(SHIPPEDDATE) as SHIPPEDYEAR from orders
• Manually editing the element expression in the crosstab editor after the crosstab has been created, as
described in , “Editing the expression of a group,” on page 383.
In this example, you could change the column element expression from $F{SHIPPEDDATE} to YEAR
($F{SHIPPEDDATE}).
10. Make sure that the fields appear in the order you want them in the crosstab. For this example, ensure that
SHIPCOUNTRY appears first in the list by selecting it and clicking Up.
Grouping by SHIPCOUNTRY and then SHIPPOSTALCODE results in each row in the crosstab referring to a
specific country, with subgroups by postal code within the country. Unlike in the main report, JasperReports
will sort the data for you, although you can disable this function to speed up the fill process if your data is
already sorted.
11. Click Next. The Measures screen is displayed.
12. Enter one or more fields you want as measures. For this example, choose ORDERID.
Measures define the detail data in the crosstab; normally, this is the result of an aggregation function like the
count of orders by country by year, or the sum of freight for the same combination (country/ year). By default,
the aggregate function is Count, which is what we want for this example. To change the aggregate function,
you would select ORDERID, click on Count, and select a different value from the drop-down menu.
16. Select the crosstab to display a border with handles. Drag the right-hand handle of the crosstab to the right
margin of the report.
17. Preview your report. You see a crosstab. The row and column headers are the values of the fields you selected
for the rows and columns. For each row and column, the value is the number of orders for that year and postal
code.
You can export a report with crosstab in the Microsoft Excel - Metadata(.xlsx) format from the JasperReports
Server. To do so, in Jaspersoft Studio, select the Ignore Pagination on the Report tab in the properties view. As
a result, you can get tabular data on a single page.
3. Drag an outline to resize the row or column. Make sure that the cells are large enough to completely contain
their content when you run the report.
2. In Outline view, select the group you want to edit. For this example, select Crosstab > Row Groups >
SHIPPOSTALCODE1.
Figure 19-12 Outline tree view – crosstab details in the crosstab editor
When you preview the crosstab, the second row group is now bucketed by the first character of the postal code.
5. To set the value class of the group, select the top-level node of the new SHIPREGION group in outline view
of the crosstab editor. Then, in the Cell tab of the properties view, enter the following value:
• Value Class Name – java.lang.String
6. Change the order of the groups by selecting the top-level node of SHIPREGION in outline view and dragging it
above SHIPPOSTALCODE.
7. Preview the report.
Expressions for elements in a crosstab, such as print-when expressions and text field expressions, can only
contain measures. In this context, you cannot use fields, variables, or parameters directly; you always have
to use a measure.
Adding a measure:
1. Create a new report:
a. Choose a blank template.
b. Select the Sample DB data adapter and click Next.
c. Enter the query select * from orders and click Next.
d. On the Fields page, select all fields and click Finish.
2. Delete all bands except the Summary band. This eliminates blank pages in the final report.
3. Add a crosstab to the Summary band with the following settings:
a. Dataset – [Main Dataset].
b. Column group – ORDERDATE; select Year from the drop-down menu in the Calculation column.
c. Row group – SHIPCOUNTRY.
d. Measure – ORDERID.
4. In design view for the report, double-click on the crosstab to open the crosstab editor.
5. Shift-click in the second row and drag to expand the row height.
6. Drag a text field into the intersection of the first row and column.
The text field is added to the column.
9. Click to the right of the Expression field to open the expression editor.
10. Add a formula to calculate the following percentage:
(Number of orders placed in this country and in this year) / (All orders placed in this country)
For Java, use the following expression:
new Double(
$V{ORDERID_MEASURE1}.doubleValue()
/
$V{ORDERID_MEASURE1_ORDERDATE1_ALL}.doubleValue()
)
(double)$V{ORDERID_MEASURE1} / (double)$V{ORDERID_MEASURE1_ORDERDATE1_ALL}
A percentage must be treated as a floating-point number. For this reason, extract the double-scalar values
from ORDERID_MEASURE1 and ORDERID_MEASURE1_ORDERDATE1_ALL objects even if they are objects of
class-type Integer.
Crosstab parameters are designed to be used in crosstab elements. They are not the same as the dataset
parameters that are used in expressions, in the crosstab context, to filter a query and calculate values.
You can set the following map properties using the Map tab:
• Map Preview – Opens a Google Maps window. This window supports standard Google Maps functionality,
such as dragging, zooming, and switching between Map and Satellite views.
Changes to this window are reflected in the map in your report. In addition, you can change the map's center in
any of the following ways. When you close the preview, the map is automatically centered at the selected
location:
• Address – Enter an address in the entry bar to center the map at that location.
• Latitude and Longitude – Enter a latitude and longitude to center your map at that location.
• Double-click – Double-click anywhere on the map to center it at that location.
• Map Type – The Google Maps view. Options are: roadmap, satellite, terrain, and hybrid.
• Latitude – The latitude of the map center. You can type directly in the entry bar, or click to enter an
expression.
• Longitude – The longitude of the map center. You can type directly in the entry bar, or click to enter an
expression.
• Address – A String representing the address of the center. You can type directly in the entry bar, or click
to enter an expression. Must be enclosed in quotes, for example, "350 Rhode Island Ave., San Francisco, CA".
• Zoom – Integer representing the Google Maps zoom level. You can type directly in the entry bar, or click
to enter an expression.
• Language – String that sets the in-map language. You can type directly in the entry bar, or click to enter
an expression. Must be enclosed in quotes, for example, "ru-RU". See the Google Maps documentation for
more information.
• Map Scale – Sets the size of the scale bar at the bottom of the map.
• Evaluation Time – Drop-down that lets you set the evaluation time of the map. See 7.3.1, “Evaluation
Time,” on page 112 for more information.
• Image Type – Drop-down that lets you set the image type to use when the map is embedded in your report.
• On Error Type – Drop-down that lets you set the type of message to display when there is an error with the
map.
Setting the property globally sets the properties when the report is run inside Jaspersoft Studio. If you are
publishing your reports to another environment, you must enable these properties in the
jasperreports.properties file in your environment.
on a dataset. A single map can include both manual markers and markers from one or more datasets. This section
describes:
• Marker Properties
• Adding Markers Manually
• Adding Markers Using the Map
• Adding Markers Using a Dataset
• Modifying Markers
5. Specify a location for your marker. You can do this by entering latitude and longitude, entering an address, or
defining markers on the map preview:
• Latitude and Longitude – Enter the latitude and longitude coordinates for your marker. You can type
directly in the entry bar, or click to enter an expression. For this example, enter the following values:
• Latitude – 37.833
• Longitude – -122.4167
• Address – The address is used only if Latitude and Longitude are blank. You can type directly in the
entry bar, or click to enter an expression.
6. (Optional) Set the title for your marker, if any.
7. (Optional) To have a new browser window or tab open with related information when a user clicks on the
marker, enter the URL and select the Target type.
8. (Optional) Set your icon type (default or custom) and icon properties:
• If you are using the default marker, you can set additional properties, such as color, label, etc. These
properties are not available for a custom icon. This example uses the color 00CCFF and the label J.
• To use a marker icon other than the default, click Custom Icon to specify a URL that points to the
image to use. Currently, we don't support loading an image directly from the repository or as a resource
local to the report. Instead, the JavaScript API loads the icon from the URL. Then set additional optional
properties for your marker, such as icon height, width, origin, and anchor.
9. Click OK to return to the Markers dialog box.
10. To create additional markers, click Add, enter the marker properties, then click OK to return to the Markers
dialog box.
11. Click OK to create your markers.
12. Once you have defined your markers, preview your report in HTML. For the example, select the Empty Data
Set for your preview.
Figure 20-7 Creating a sample data adapter for markers and paths
7. Click Get column names from the first row of the file.
8. Select Skip the first line.
9. Click Finish to create the adapter.
8. For a dataset, you typically want to use expressions for your values. For each property you want to read from
the dataset, click on the entry bar, select Use Expression and enter the expression to use. For this
example, use the following expressions:
• Latitude – $F{latitude}
• Longitude – $F{longitude}
• Address – $F{landmark}
You can use expressions to pass parameters to a map component dynamically. Expressions allow you
to evaluate data in your dataset and use the results to populate the map. In the component's properties,
properties based on expressions show f(x) next to the field.
9. Click OK. The Markers dialog box displays the markers you just created.
10. Click OK. Your markers are displayed on the Marker tab of the Properties view, along with any other markers
you have created.
Figure 20-11 Properties view showing markers added manually and markers defined from a
dataset
11. Preview your report in HTML. The example below shows the markers from the sample dataset along with a
static marker.
To delete a marker:
1. Select the map and click on the Markers tab in Properties view.
2. Select the marker you want to delete and click Delete.
Figure 20-13 Styles on the Path tab of the Properties view for a map
4. Select your path from the Paths menu. The Paths menu has the following characteristics:
• If you already have static paths defined for your map, you can select a path name from the Paths menu.
Points you create are added to the currently-selected path. You can switch between paths at any time.
• If you have not created any static paths, then you can enter a name on this menu. If a static path already
exists, you cannot create a new one.
5. To add a point to the current path, right-click on the location you want and select Add marker.
6. To delete one or more markers, select the marker(s) in the panel at the right and press Delete, or right-click on
the marker and select Delete.
Property Description
Name String. Name used to identify the marker or path; must be unique for markers or paths in the
report.
Latitude Number between -90 and 90. The latitude of a location in degrees.
Property Description
Longitude Number between -180 and 180. The longitude of a location in degrees.
Address String. The address or placeID of a location. Only used if Latitude and Longitude are not avail-
able.
Color String. The color of the path or marker. For best results, use hexadecimal representation, as not
all Google API implementations will support color strings.
Clickable Boolean. When true, the marker or path can handle mouse events. Default is true.
Draggable Boolean. When true, a user can drag the marker or path contour. Default is false.
Visible Boolean. When true, the marker or path is visible. Defaults to true.
Z Index Number. Index determining the order in which objects are displayed on the map. Elements with
higher values are displayed in front of similar elements with lower values. Markers are always
displayed in front of paths.
Custom Icon Use Custom Icon settings to use a marker icon other than the default. You must specify a URL
that points to the image to use. Currently, we don't support loading an image directly from the
repository or as a resource local to the report. Instead, the JavaScript API loads the icon from
the URL.
You can set additional optional properties for your marker, such as icon height, width, origin,
and anchor.
Custom Use Custom Shadow Icon settings to use a shadow icon other than the default. You must
Shadow Icon specify a URL that points to the image to use. Currently, we don't support loading an image
directly from the repository or as a resource local to the report. Instead, the JavaScript API loads
the icon from the URL.
You can set additional optional properties for your shadow, such as height, width, origin, and
anchor.
Info Window Use Info Window settings to add an info window. You can define the window content, pixel off-
set, and maximum width.
Label String. Single character that appears on the marker. Not available for custom markers.
Property Description
Cursor String. Mouse cursor to show on hover. Not available for custom markers.
Parent Style String. Name of path style to use as a parent style. The current style inherits the parent's
properties if the parent style is present in the report. Elements set locally in the current style
override elements set in the parent.
Stroke Color String. Color of the stroke; for most consistent results, use hexadecimal format. Default is
#000000.
Stroke Opacity Number. The path's opacity. Number between 0 (transparent) and 1 (opaque). Default is 1.
Fill Color String. Color of the fill for the polygon when Is Polygon is true. Takes values hexadecimal
format. Default is null.
Fill Opacity Number. The opacity for the polygon's fill when Is Polygon is true. Number between 0 (trans-
parent) and 1 (opaque). Default is 1.
Is Polygon Boolean. When true, creates a polygon (closed path) by connecting the last point on the path
to the first point. Default is false (open polyline).
Editable Boolean. When true, a user can edit the path by dragging the control points on the path line.
Default is false.
Geodesic Boolean. When true, dragged paths follow the great circles on the earth's surface; in this case,
since the map is a projection, the lines may not appear straight. When false, paths are straight
lines on the map. Defaults to false.
This section describes functionality that can be restricted by the software license for JasperReports Server. If you
don’t see some of the options described in this section, your license may prohibit you from using them. To find out
what you're licensed to use, or to upgrade your license, contact Jaspersoft.
In addition to the other types of map component that Jaspersoft Studio supports, TIBCO GeoAnalytics Maps are also supported. These multi-layer maps are
designed for use in interactive web environments, and support both markers and paths. They also support the ability to provide a street address and resolve it to
the correct latitude and longitude (sometimes called geolocation).
Because these components download content from either TIBCO's service or from Google Maps, they require a connection to the Internet. While the maps
themselves are freely available, using the GeoAnalytics geolocation serve to resolve street addresses requires an additional license.
These maps are well suited to web-based environments, such as HTML export or when viewed through an
interactive viewer such as JasperReports Server; however, limitations in the underlying technology prevent some
TIBCO GeoAnalytics Map features from working in static formats, such as PDF. In this case, the map is converted
to an image, which is always downloaded from Google Maps instead of TIBCO's server. In addition, if the map's
location is resolved from a street address, the canvas may be blank (or blue); this happens when the address's
latitude and longitude aren't available.
If your target output format is something other than HTML, consider using the standard map component.
The map component consists of three layers: a map, a set of paths, and a set of markers. The lowest layer contains the map itself, rendered by your choice of
providers: TIBCO Maps or Google Maps. In both cases, the image is formed of tiles retrieved from a remote server. The next two layers (first paths then
markers) can contain paths and markers or shapes.
1. First locate the component in the Palette; it uses this icon: ;drag it onto the canvas.
At a minimum, the TIBCO Map component requires the location of the area to display, which can be defined by these manually-exclusive options:
a. The latitude and longitude of the location.
b. The street address of the location (assuming you have a license for TIBCO GeoAnalytics geolocation services). To use this option, you must also
provide credentials for TIBCO's geolocation service. You can either enter these in the Maparama Credentials section of the TIBCO map component's
properties, or by defining them in the jasperreports.properties file so that they can shared across multiple reports. These properties are:
• com.jaspersoft.jasperreports.tibco.maps.customer - the customer name used with TIBCO GeoAnalytics Maps
• com.jaspersoft.jasperreports.tibco.maps.key - the corresponding license key for the specified user
2. To define a location, edit the TIBCO Maps component's Location properties. Entering a latitude/longitude pair or address defines a static location. You can
also use parameters to dynamically define the components location as well as all other TIBCO Map properties.
Map attributes determine how the map layer of the component is rendered. The attributes are all optional:
Use Canvas true false This property refers to the way the map is rendered (by using a canvas or SVG layers)
Repeat X true | false Specifies whether tiles are repeated when the world's bounds are exceeded horizontally
To specify a different dataset to resolve the map attributes based on expressions, click the Use Dataset check box to select it, and select the dataset to use in
the Dataset Run.
Figure 21-4 Defining the Dataset to use to resolve map attribute expressions
Data Runs are used throughout Jaspersoft Studio and its related products when a report includes a subdataset. Use a Data Run to define values for the
subdataset's parameters.
Figure 21-5 Layer names defined in the component can control the layers drawn in the final report
4. Specify the icon as a URL that points to the image to use; it's loaded by the JavaScript API.
Jaspersoft doesn't currently support loading an image directly from the repository, or as a resource local to the report.
The location can be set by latitude/longitude coordinates or an address to be geolocated, as described above.
5. For the addresses, set each property to form the address: country, state, zip, city, street.
xoffset Numeric Optional 0 The horizontal offset of the marker icon measured in pixels
(integer)
yoffset Numeric Optional 0 The vertical offset of the marker icon measured in pixels
(integer)
anchor String Optional bottom-left, bottom-right, bottom- The anchor point of the marker icon
center
draggable Boolean Optional false Specifies whether users can drag the marker
title String Optional N/A The ToolTip for the marker icon; works in conjunction with
icon.url
hyperlink String Optional N/A The hyperlink text for the marker
target String Optional N/A The hyperlink target for the marker. The default value is _
blank.
This is a simplified example; the more common scenario is to read location data from the database.
Civic Center 750 Eddy Street San Francisco CA 94109 37.783008003000475 -122.42000284399973
Fort Mason Laguna Street & Marina San Francisco CA 94123 37.80001344200048 -122.43517818299972
Boulevard, Building B
John Adams 1860 Hayes Street San Francisco CA 94117 37.77385843900049 -122.4469528999997
Gough Street 31/33 Gough Street San Francisco CA 94103 37.772268634000454 -122.42098248799971
Since the data set includes both street addresses and latitude/longitude pairs, we can explore both functions.
This example uses an icon from the web: Pink Push Pin.
14. Click OK.
15. Preview your report in HTML.
5. Enlarge the Summary band to 500 pixels by changing the Height entry in the Band Properties view.
2. On the Map Formatting tab, select the Map section and set the Background Color, for this example, enter
the following value:
• Background Color: #14D9D5
3. Select the Borders and Plot Area section and enter the following values:
• Plot Shadow: true
• Plot Background Color: #F2EB1D
• Plot Border Color: #F7072B
• Plot Border Width: 1 px
• Border Color: #130FFA (this refers to the map regions outside the plot area)
• Border Radius: 4 px
• Border Width: 3 px
4. To preview the map from inside the dialog box, click Show Map Preview.
You can color each state or region with a different color. To do so, select the Plot Options section and set Color
by Point to true. Color for each region is picked from the Color Palette. The process flows in a circular way.
When the last color is picked up from the palette, the next color is the first color in the same palette.
Figure 22-5 Simple Map with Inner Borders and Color by Point Property Enabled
2. Choose Sample DB from the data adapters list in the upper-left corner and enter the SQL query in the query
panel, for example:
4. If there is no hc-key under Measures, click Add and follow step 4 to step 11 to add hc-key value for each
chart data point. Enter the following values:
• Name: hc-key
• Select the Hidden check box
• Label Expression: $F{hc-key}
• Calculation: Nothing
• Value Expression: $F{hc-key}
• Value Class Name: java.lang.String
5. Click OK.
6. Under Measures, select Measure1 and click Modify.
7. Click the Advanced Properties tab and click Add. The Edit Property dialog is displayed.
8. Set the following values:
• Contributor: SeriesItemProperty
• Property Name: hc-key
9. Select the Use Measure Value and then select hc-key from the drop-down list.
You can see that color of the map has been changed. This is because when you link the chart data to the map, the
Color Axis property takes precedence over the Color by Point property.
5. To add hc_a2 value for each chart data point, on the Data Configuration tab, click Switch to advanced
configuration.
6. In the Measures section, click Add. The Measure dialog is displayed.
a. Enter the following values:
• Name: hc_a2
• Select the Hidden check box
• Label Expression: $F{hc_a2}
• Calculation: Nothing
• Value Expression: $F{hc_a2}
• Value Class Name: java.lang.String
b. Click OK.
c. Under Measures, select Measure1 and click Modify.
d. Click the Advanced Properties tab and click Add. The Edit Property dialog is displayed.
e. Set the following values:
• Contributor: SeriesItemProperty
• Property Name: hc_a2
• Select the Use Measure Value and then select hc_a2 from the drop-down list.
7. In the Plot Options section, select Data Labels and set the following:
• Enabled: true
• Format: {point.hc_a2}
8. Click to refresh the preview.
In the join expression, always start with the name of the field in the GeoJSON map data (that is "hc-a2").
2. Click to refresh the preview. You can see that data is correctly mapped and the map remains the same.
Figure 22-14 Displaying Data for the West Region of the United States
In case you provide null for the Value Expression and set the inner borders visible and the Render All Areas
to false, the map looks like this:
To create a hyperlink:
1. Change the expression of Value Expression back to $F{value}.
2. Under Measures, click Add to add a new hidden measure and enter the following information:
• Name: linkName
• Select the Hidden check box.
• Label Expression: $F{name}
• Calculation: Nothing
• Value Expression: "https://en.wikipedia.org/wiki/" +$F{name}
• Value Class Name: java.lang.String
3. Click OK.
4. Select Measure1 and click Modify.
5. Click Edit Hyperlink. The Edit Hyperlink Information dialog is displayed.
6. Enter the following information:
• Select Use Hyperlink check box.
• Hyperlink Target: Blank
• Hyperlink Type: Reference
• Select Use Measure Value and then select linkName from the list.
7. Click OK
8. Click OK again.
9. Preview the map. In the HTML Preview, click the state to open the associated wiki page for that state.
Because the HTML5 maps are two-dimensional, setting the Zoom Type to ‘x’ or ‘y’ generates only
proportional responses. For instance, if Zoom Type is set to ‘x’ only, the ‘y’ dimension cannot grow beyond
the y-axis bounds, it will enlarge with a small fraction. As a consequence, the ‘x’ dimension enlarges
proportionally with the same fraction.
The zoomed region is magnified, you can also reset the map dimensions to their initial values by clicking the
Reset zoom button in the upper-right corner of the Preview window.
The map navigation control button is added on the upper-left corner in the Preview window; you can click the "+"
or "-" button to zoom in or zoom out the map.
Reflecting standard Eclipse design, saving or previewing a report that contains subreports does not update
the subreports. When you edit a subreport, you must explicitly save and build the subreport in order for the
changes to be visible when you preview the report that contains it. To build a subreport, right-click the project
in the Project Explorer and select Build Project, or type Ctrl-B to build all projects in the workspace.
Subreports also let you combine two or more child lists of data relating to a single parent element, for example, a
report with multiple detail bands of different types. You map parameters between the master report and its
subreports to create a blended report where each subreport displays details for each record from the master report.
As the master report executes, each time a subreport element is reached, it is executed and its content is embedded
into the output of the master report.
Uses for subreports include:
• Modularizing reports – You can create a subreport with your preferred data fields and layout, then use the
subreport in multiple master reports.
• Combining multiple queries or data sources in a single report.
2. Select Create a new report and click Next. The New Report Wizard > Report Templates window is
displayed.
3. Select a template for your subreport. For this example, select one of the blank templates. Click Next. The
New Report Wizard > Report file window opens.
4. Select a location for your subreport, and name it. Click Next. The Data Source window opens.
5. Choose to use the same data adapter as the main report, or a different data adapter.
For this example, choose the same adapter (Sample DB). Enter the following SQL query:
select count (*), shipcity from orders group by shipcity
6. Click Next.
7. Add all the fields to the list on the right. Click Next.
8. Click Next to skip the Group By step. The Subreport > Connection window opens.
9. Choose to connect either to the same database as the main report or to a different database. For this example,
click Use same connection used to fill the master report.
10. Click Next. The Subreport Parameters window opens.
11. For this example, skip this window and click Finish. A new report opens containing all bands.
12. Delete all bands but the Title or Summary band to eliminate extra white space in your report.
You now have a location into which to place your table, chart, or other element attached to the new subreport.
23.2.1 Subreports
A subreport is simply a report composed of its own JRXML source and compiled in a Jasper file. Generally
speaking, creating a subreport is very similar to creating any other report. The margins of a subreport are usually
set to zero for subreports because a subreport is meant to be a portion of a page, not an entire document. The
horizontal dimension of the subreport should be as large as the element into which it is placed in the parent report.
The Subreport element does not need to be the same size as the subreport. You can think of the Subreport
element as a place holder defining the position of the top-left corner to which the subreport is aligned.
However, we recommend that you set the dimensions of the Subreport element to the dimensions of the
subreport to best visualize the layout of the final report.
Property Description
Run To Bottom When true, the subreport element will consume the entire vertical space available on
the report page.
Overflow Type When not specified, the subreport will stretch to accommodate the content.
Expression (Required) Expression that can be used to load the Jasper object to use when filling
the subreport portion of the document. Evaluated at run time to retrieve the Jasper
object for the subreport.
See 23.2.3, “The Expression Property,” on page 452 for more information.
Using Cache Specifies whether the subreport's report object is kept in memory or reloaded each
time it's used. It is common for a subreport element to be printed more than once (or
once for each record in the main dataset).
The cache works only if the subreport expression type is String, because that
string is used as key for the cache.
Connection Expression At run time, returns a JDBC connection or a JRDataSource used to fill in the
or subreport. Only one of these expression types can be used.
Datasource Expression If there is no connection or data source expression, no data is passed to the
subreport. This option is useful at times. In this case, the subreport should have the
document property When No Data Type set to something like All Sections,
No Detail or No Data Section.
Parameters Map Optional expression used to produce a java.util.Map object at run time. The
Expression expression must contain a set of coupled names/objects that are passed to the
subreport to set a value for its parameters.
Edit Return Values Allows you to define how to store values in local variables calculated or processed in
the subreport (such as totals and record count).
Edit Parameters Allows you to define name/expression pairs used to dynamically set a value for the
subreport parameters.
The following properties must be set to link the subreport to the parent report:
• Expression – Retrieves the Jasper object that implements the subreport.
• Connection Expression or Datasource Expression – Defines how to feed the object with data.
• Parameters – Sets the values of the subreport parameters.
You can't use a relative path to locate the subreport file; that is, if you have a report in c:\myreport\main_
report.jasper, you cannot refer to a subreport using an expression like ..\\mysubreports\\mysubreport.jasper.
This is because JasperReports does not keep in memory the original location of the Jasper file that it’s
working with. This makes perfect sense, considering that a Jasper object is not necessarily loaded from a
physical file.
To simplify report design when loading a subreport from the file system, do one of the following:
• Place the subreport file in a directory that is in the classpath. This permits you to use very simple subreport
expressions, such as a string containing just the name of the subreport file (that is, “subreport.jasper”).
Jaspersoft Studio always includes the classpath of the directory of the report that is running, so all the
subreport Jasper files can be found easily if they are located in the same directory.
• Parametrize the Jasper file location and create on-the-fly the real absolute path of the file to load. This can be
achieved with a parameter containing the parent directory of the subreport (let’s call it SUBREPORT_
DIRECTORY) and an expression like this:
$P{SUBREPORT_DIRECTORY} + "subreport.jasper"
One advantage of this approach is that you can use the Jasper files’ local directory as the default value for the
SUBREPORT_DIRECTORY parameter. The developer who will integrate JasperReports in his applications can set
a different value for that location just by passing a different value for the SUBREPORT_DIRECTORY parameter.
• Use an empty datasource – Select this to set the data source expression to new JREmptyDataSource().
That creates a special data source that provides a single record with all the field values set to null. This is
useful when the subreport is used to display static content such as headers, footers, and backgrounds. In this
case, in the subreport, set the report property When no data type to All Data No Details or No Data
Section to ensure that at least a portion of the document is actually printed.
JDBC connections make using subreports simple enough. A connection expression must identify a
java.sql.Connection object (ready to be used, so a connection to the database is already opened). Typically,
we’ll run the SQL query using the same database connection as the parent report; the connection can be referenced
with the REPORT_CONNECTION built-in parameter. It must be clear that if we pass a JDBC connection to the
subreport, it is because we defined an SQL query in the subreport, a query that will be used to fill it.
Using a different data source is sometimes necessary when a connection like JDBC is not being used; it is more
complicated but extremely powerful. It requires writing a data source expression that returns a JRDataSource
instance that you then use to fill the subreport. Depending on what you want to achieve, you can pass the data
source that will feed the subreport through a parameter, or you can define the data source dynamically every time it
is required. If the parent report is executed using a data source, this data source is stored in the REPORT_
DATASOURCE built-in parameter. On the other hand, the REPORT_DATASOURCE should never be used to feed a
subreport; a data source is a consumable object that is usable for feeding a report only once. Therefore, the
parameter technique is not suitable when every record of the master report has its own subreport (unless there is
only one record in the master report). When we discuss data sources this will be more clear and you will see how
this problem is easily solved with custom data sources. You will also see how to create subreports using different
type of connections and data sources.
To pass parameters from the master report to a subreport, you create a set of parameter name/object pairs that feed
the parameters map of the subreport. To do this, click the Edit Parameters button on the Subreport tab of the
Properties view to open the Subreport Parameters dialog.
When a report is invoked from a program (using one of the fillReport methods, for instance), a
parameters map is passed to set a value for its parameters. A similar approach is used to set a value for
subreport parameters. With subreports you don’t have to define a map (even, if possible, specifying a
Parameters Map Expression). The report engine will take care of that for you.
To configure a parameter you want to pass to the subreport, click Add in the Subreport Parameters dialog to open
the Parameter Configuration Dialog box, which lets you set the following:
• Name – Name of the parameter. A parameter must have the same name in the master report and the subreport.
Parameter names are case-sensitive.
If you make an error typing the name or the inserted parameter has not been defined, no error is thrown. In
most cases, the report will fail silently.
• ValueExpression – JasperReports expression for the parameter. To create or edit an expression, click to
open the expression editor. You can use fields, parameters, and variables. The return type has to be congruent
with the parameter type declared in the subreport; otherwise, an exception of ClassCastException will
occur at run time.
As cited below, you have the option of directly providing a parameters map to be used with the subreport; the
Parameters Map Expression allows you to define an expression, the result of which must be a
java.util.Map object. It is possible, for example, to prepare a map designed for the subreport in your
application, pass it to the master report using a parameter, then use that parameter as an expression (for example,
$P{myMap}) to pass the map to the subreport. It is also possible to pass to the subreport the same parameters map
that was provided to the parent by using the built-in parameter REPORT_PARAMETERS_MAP. In this case the
expression looks like this:
$P{REPORT_PARAMETERS_MAP}
Since the subreport parameters can be used in conjunction with this map, you could even use it to pass common
parameters, such as the username of the user executing the report.
You can also create JasperReports Server templates and upload them to the server. See 12.4, “Working
with JasperReports Server Templates,” on page 222.
A template contains all or some of the same parts as a report. Remember the following when creating a new
template or editing an existing template:
• A report's page formatting is the page formatting of its template.
• Each band in a report is, by default, the same size as that band in its template.
• Every element placed in the Summary, Title, Page Header and Page Footer bands, of a template appears
in every report that uses that template.
• The Column Header band should contain only a Static Text element, and its text content must be Label.
The appearance, font and the other attributes of this label create every label inserted in this band.
• The Group Header band should contain only a Text Field with the string “GroupField” (including the
double quotes). As with the Column Header this assumes an example to generate every field that goes in this
band.
• The Detail band should contain only a Text Filed with the string “Field” (including the double quotes).
Again, this is used to generate every field that goes in this band.
When you group data using the wizard, the wizard creates all the necessary report structures to produce your
groups. The Report Wizard supports up to four groups, with a group header and group footer associated with each.
If the template defines one or more groups and you group the data, the wizard tries to use any existing groups
before creating new ones. By default, groups in the template are deleted if they're not used. For each group, the
wizard sets the group expression and adds a label for the name and a text field showing the value of the group
expression (which is always a field name, because the grouping criteria set using the wizard is one of the selected
fields).
5. Right-click on the report root node in the Outline, and select Create Group. The Group Band dialog is
displayed.
6. Name your group and click Next. The Group Layout dialog is displayed.
7. Leave both Add the Group Header and Add the Group Footer checked, and click Finish.
Your report is similar to the one in Figure 24-5.
To customize a template:
1. Add a graphic: Drag an Image element where you want the image to appear. This is usually the Title band.
For more information about the Image element, see “Graphic Elements” on page 60.
2. Add a title: Drag a Static Text element to the Title band. Style the text in the Properties view. For more
information about Static Text elements, see “Text Elements” on page 61.
3. Want the background to cover the entire page? Right-click the element in the Outline and choose Maximize
Band Height. Otherwise, set the Background band to the size you want. Drag an Image element into the
Background band to create your background.
4. Add page numbering to the Page Footer band: Drag a Page Number element into the band, and place it
where you want it. You can also add a Page X of Y element if you prefer.
5. Want a label in the Column Header band? Add a Static Text element with the text “Label”.
6. Set styles for your report’s text: Add a Text field to the Group Header and a Text field to the Detail band. Set
the text of the first Text field to “GroupField” and the text of the second Text field to “Field”. Format the
text as you like.
7. Save your template file.
8. Click the Preview tab. Your template should like something like the one in Figure 24-6.
2. Click the New... button and navigate to the directory in which you want to store your template.
3. Click the Apply button.
4. Click OK.
2. Click the Browse button and navigate to the directory where you want to save your template. Click Next.
The Define Type and Categories dialog opens.
3. In the drop-down, choose whether the template type is a Standard Report or a Table-Based report.
This selection is used to validate the report. For example. by selecting Standard Report, the validation
process searches for the group field with the text group or for the column header label with the text label. If
any of the required fields are not found, an error message is displayed.
4. Select the categories for the template available and use the arrow button to add them to the Selected
Categories.
5. Click Finish.
3. Click Next.
4. Select sugarcrm - Database JDBC Connection and click Next.
5. Enter the query select * from accounts and click Next.
6. Select the following fields and click the right arrow to add them to your report.
billing_address_country
billing_address_street
billing_address_city
name
7. Click Next.
8. Group the fields by the element that triggers the report splitting. To do this, select the billing_address_
country field and click the right arrow.
15. Run the report in the scheduler. To do this, right-click the report and select Run in Background from the
context menu.
16. On the Output Options tab, set the output options and click Submit.
17. On the Notifications tab, enter the email address and subject of the email to be sent to each recipient.
Provide dynamic values in the following text fields To, CC, and Subject.
18. Select the Include report files as attachments option and click Submit.
A single report is split into three separate reports and sent to the email address of different recipients.
In Jaspersoft Studio, open the Project Explorer and expand the My Reports folder. There, you can see the jrxml
files you just created:
• Sample_Book_backcover.jrxml
• Sample_Book_cover.jrxml
• Sample_Book_toc.jrxml
• Sample_Book.jrxml
Sample_Book.jrxml is open in the main Design tab. This is the file in which you'll organize the report parts. You'll
notice three groups for the book part types:
• Cover and Table of Contents contains Sample_Book_cover.jrxml and Sample_Book_toc.jrxml.
• Content is currently empty.
• Backcover contains Sample_Book_backcover.jrxml
When you select each these book parts in the design window, you can view and edit their properties in the
Properties View, as you can with standard reports and subreports.
Next, you'll create a subreport and add it to your report book.
2. Drag Content_Page_One.jasper from the Project Explorer into the Content group. In the Connection
dialog, click Finish.
3. In the Design tab, click to select Content_Page_One.jasper.
4. In the Properties view, click the Data button at the top, then click Edit Parameters.
5. In the Report Part Parameters window, click Add to open the Parameter Configuration dialog.
6. In the Parameter Name field, enter REPORT_CONNECTION.
7. Click to open the Expression Editor.
8. In the first column, select Parameters.
9. In the center column, double-click REPORT_CONNECTION parameter connection to add it to the
editor field, and click Finish. The expression appears in the Parameter Configuration field.
10. Click OK and confirm the parameter has been added to the Part Parameters list, then click Finish.
4. In the Designer view, click to open the Dataset and Query Dialog.
5. Modify the query to say:
select count(*) c, shipcity from orders where shipcountry = $P{Country} group by
shipcity
6. Click OK.
7. Save Country_Intro.jrxml.
8. In the Outline view, drag Country from the Parameters list into the Title band.
9. Click the Country parameter ($P{Country}).
10. In the Properties view, click Text Field. Increase the font size to 26.
11. Click outside the parameter element.
Next, you can add a chart to the intro pages, that provides a graphical representation of the data in the section.
5. Click the Chart Data tab, then click the Configuration tab.
6. In the Categories Levels section, double-click Level1.
7. In the Expression text box, delete "Change Me" and click .
8. Select Fields from the first column, and double-click SHIPCITY Field String to add it to the expression.
9. Click Finish.
10. Update the Name field to "City" and click OK.
11. Back in the Chart Properties dialog, update the following information:
• Name: Number of orders.
• Label Expression: "Number of orders"
• Calculation: Nothing
• Value Expression: Delete new Integer1, click , and double-click C Field Long, then click Finish.
12. Click OK, then save the report.
13. Compile Country_Intro.jrxml to create a .jasper file.
Now, you can add the Country_Intro page to your book, and configure it to display the correct data.
The Table of Contents is derived from a special data source created by JasperReports and included as a property in
the report book. This property, net.sf.jasperreports.bookmarks.data.source.parameter, collects
bookmarks from the report book's content pages. So you'll need to add bookmarks to your reports.
To add bookmarks:
1. Open Country_Intro.jrxml in the Design tab.
2. Click the Country parameter in the Title band.
3. In the Properties view, click Hyperlink.
4. Expand the Anchor and Bookmark section.
5. Click to open the Expression Editor, and click Parameters.
6. Double-click Country Parameter String to add it to the expression, then click Finish.
7. In the Properties view, change the Bookmark Level to 1.
8. Click outside the design space in the Design tab, then click Report in the Properties view.
9. Click to enable Create bookmarks.
10. Open the Content_Page_One.jrxml in the Design tab.
11. Click the $F{SHIPCITY} text band.
12. In the Properties view, click Hyperlink.
13. Expand the Anchor and Bookmark section.
14. Click to open the Expression Editor, and click Fields.
15. Double-click SHIPCITY Field String to add it to the expression, then click Finish.
16. In the Properties view, change the Bookmark Level to 2.
17. Save all files, and compile the Sample_Book.jrxml.
26.1 Properties
You can set JasperReports properties in the Jaspersoft Studio > Properties page of the Preferences window.
Setting a property here sets it as the default for all reports. You can also set many properties at the report or
element level. A property set at the element level overrides a property set at the report level; a property set at the
report level overrides a property set at the Jaspersoft Studio level.
26.3.1 Configuration
You can set two preferred (default) units of measure, one at the field level, the other at the report level. The report
level unit is used wherever there is not a preferred field unit of measure. The report's default unit of measure is the
pixel.
Enter a value and begin typing a unit of measure. Auto-complete will list the matching supported values for you to
choose from.
26.3.4 Approximations
Even through Jaspersoft Studio handles many units of measure, JasperReports works only with pixels. So pixels are
the only unit allowed in the project file. Jaspersoft Studio approximates measurements and converts them to pixels.
For example, 5 cm is converted to the nearest whole-number value in pixels. In this case the 5 centimeters is
converted to 139 pixels (approximately 4.97 cm).
26.4.1.1 Mac OS X
To set the clean flag at startup on Mac OS X, run the following commands:
cd <jss-install>/Contents/MacOS
./Jaspersoft\ Studio\ Professional -clean
26.4.1.2 Linux
To set the clean flag at startup on Linux, run the following commands:
cd <jss-install>
./Jaspersoft\ Studio\ Professional -clean
26.4.1.3 Windows
To set the clean flag at startup on Windows, edit the desktop shortcut as follows:
1. Right-click on the desktop shortcut and select Properties.
2. On the Shortcut tab, append -clean to the Target field. For example:
"<jss-install>\Jaspersoft Studio Professional" -clean
3. Click OK.
4. Double-click the shortcut to run the application.
5. Once you have cleaned the application, edit the shortcut again to remove the -clean flag to avoid slowing
down application startup.
The Jaspersoft Studio application logger preferences cannot be exported, since they are determined in part
by your application INI configuration.
You can choose to export all of these categories or only a subset of them; however, you can't choose individual
items inside a category. The result of the export is a single zip file (compressed archive), which can be imported
into another Jaspersoft Studio instance. Again, you can choose which of the available categories inside the zip you
want to import.
4. Select the resource categories you want to import and click Finish.
5. If there is a naming conflict between an imported resource and an existing resource in your Jaspersoft Studio
configuration, choose the action in you want in the displayed dialog. For resource categories other than
Jaspersoft Studio properties and JasperReports Library properties, you have three choices:
• Overwrite – Overwrites the existing resource(s) with the imported resource(s) of the same name.
• Keep both – Automatically renames the conflicting imported resource(s) with a unique name.
• Skip – Keeps the existing resources and discards the imported resources.
For Jaspersoft Studio properties and JasperReports Library properties, which do not support multiple instances,
you are prompted to choose to overwrite or not.
As before, you must choose the same action for all conflicting resources in a category. For example, if you
have multiple conflicting global data adapters, you must overwrite, keep both, or skip all global data adapters.
A separate dialog is shown for each category where you have conflicting resources. You can choose different
actions for different categories.
Studio to use an earlier version of JasperReports Library to compile your reports. If you do this, any features in
your reports that rely on a later version of JasperReports Library will not be available.
If you are exporting your reports to JasperReports Server, you should configure the version in the
JasperReports Server connection settings, as described in 12.1.1, “Advanced Connection Settings,” on
page 209. Use the compatibility setting only if you are using your reports on your own application built from
JasperReports Library.
3. To save your reports in an earlier version of JRXML, select the version you want from the Version menu in
the Source .jrxml Version section of the dialog.
4. To remove Jaspersoft Studio properties from your compiled reports, select Don't save Jaspersoft Studio
properties. Properties specific to Jaspersoft Studio include some layout information, dimensions in pixels or
millimeters, and the data adapter that was most recently used in Jaspersoft Studio.
5. To use an earlier version of JasperReports Library to compile reports, select the version you from the Version
menu in the Compiler Settings section of the dialog. If the version you want is not available, set it up as
described in the next step.
6. To add a version of JasperReports Library to the Version menu in the Compiler Settings section of the dialog
click Manage JasperReports Versions and select the version you want:
a. To use a version you already have installed, click Add From Path, then select the directory where the
JasperReports Library is located.
Jaspersoft Studio verifies that the path contains JasperReports Library and adds the version to the
Version menu in the Compiler Settings section of the Compatibility dialog.
b. To download and install JasperReports Library from a URL, click Add From URL and select the
URL from SourceForge (https://sourceforge.net/projects/jasperreports/) or from another location.
Jaspersoft Studio downloads and verifies the jar files, copies the files to a Jaspersoft Studio internal
directory, and adds the version to the Version menu in the Compiler Settings section of the Compatibility
dialog.
The Eclipse UI changes to the Java perspective. A Java icon is added to the top right of the Eclipse window. In
future, you can switch to this perspective by clicking . To switch back to the Jaspersoft Studio perspective, click
the Report Design icon .
Jaspersoft Studio is primarily focused on report development, though it is able to preview the result and export it in
all the supported formats. Jaspersoft Studio provides support for a wide range of data sources and allows users to
create custom data sources, thereby becoming a complete environment for report development and testing.
When you design a report, you specify where the data comes from, how it is positioned on the page, and additional
functionality, such as parameters for input controls or complex formulas to perform calculations. The result is a
template, similar to a form containing blank space, that is filled with data when the report is executed. The template
is stored in a JRXML file, which is an XML document that contains the definition of the report layout and design.
Before executing a report, the JRXML must be compiled in a binary object called a Jasper file. Jasper files are
what you need to ship with your application in order to run the reports.
Report execution is performed by passing a Jasper file and a data source to JasperReports. There are many data
source types. You can fill a Jasper file from an SQL query, an XML file, a .csv file, an HQL (Hibernate Query
Language) query, a collection of JavaBeans, and others. If you don't have a suitable data source, JasperReports
allows you to write your own custom data source. With a Jasper file and a data source, JasperReports is able to
generate the final document in the format you want.
Jaspersoft Studio also lets you configure data sources and use them to test your reports. In many cases, data-driven
wizards can help you design your reports much quicker. Jaspersoft Studio includes the JasperReports engine itself
to let you preview your report output, test, and refine your reports.
<group name="CITY">
<groupExpression><![CDATA[$F{CITY}]]></groupExpression>
<groupHeader>
<band height="27">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="139" height="27"
forecolor="#FFFFFF" backcolor="#000000"/>
<textElement>
<font size="18"/>
</textElement>
<text><![CDATA[CITY]]></text>
</staticText>
<textField hyperlinkType="None">
<reportElement mode="Opaque" x="139" y="0" width="416" height="27"
forecolor="#FFFFFF" backcolor="#000000"/>
<textElement>
<font size="18" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{CITY}]]>
</textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="8">
<line direction="BottomUp">
<reportElement key="line" x="1" y="4" width="554" height="1"/>
</line>
</band>
</groupFooter>
</group>
<background>
<band/>
</background>
<title>
<band height="58">
<line>
<reportElement x="0" y="8" width="555" height="1"/>
</line>
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="51" width="555"
height="1"/>
</line>
<staticText>
<reportElement x=”65” y=”13” width ”424” height=”35”/>
<textElement textAlignment=”Center”>
<font size=”26” isBold=”true”/>
</textElement>
<text><![CDATA[Classic template]]> </text>
</staticText>
</band>
</title>
<pageHeader>
<band/>
</pageHeader>
<columnHeader>
<band height="18">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="138" height="18"
forecolor="#FFFFFF" backcolor="#999999"/>
<textElement>
<font size="12"/>
</textElement>
<text><![CDATA[ID]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="138" y="0" width="138" height="18"
forecolor="#FFFFFF" backcolor="#999999"/>
<textElement>
<font size="12"/>
</textElement>
<text><![CDATA[FIRSTNAME]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="276" y="0" width="138" height="18"
forecolor="#FFFFFF" backcolor="#999999"/>
<textElement>
<font size="12"/>
</textElement>
<text><![CDATA[LASTNAME]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="414" y="0" width="138" height="18"
forecolor="#FFFFFF" backcolor="#999999"/>
<textElement>
<font size="12"/>
</textElement>
<text><![CDATA[STREET]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20">
<textField hyperlinkType="None">
<reportElement x="0" y="0" width="138" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{ID}]]>
</textFieldExpression>
</textField>
<textField hyperlinkType="None">
<reportElement x="138" y="0" width="138" height="20"/>
</textField>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{FIRSTNAME}]]>
</textFieldExpression>
<textField hyperlinkType="None">
<reportElement x="276" y="0" width="138" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{LASTNAME}]]>
</textFieldExpression>
</textField>
<textField hyperlinkType="None">
<reportElement x="414" y="0" width="138" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{STREET}]]>
</textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band/>
</columnFooter>
<pageFooter>
<band height="26">
<textField evaluationTime="Report" pattern="" isBlankWhenNull="false"
hyperlinkType="None">
<reportElement key="textField" x="516" y="6" width="36" height="19"
forecolor="#000000" backcolor="#FFFFFF"/>
<textElement>
<font size="10"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["" +
$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField pattern="" isBlankWhenNull="false" hyperlinkType="None">
<reportElement key="textField" x="342" y="6" width="170" height="19"
forecolor="#000000" backcolor="#FFFFFF"/>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Right">
<font size="10"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Page " +
$V{PAGE_NUMBER} + " of "]]></textFieldExpression>
</textField>
During compilation of the JRXML file (using some JasperReports classes) the XML is parsed and loaded in a
JasperDesign object, which is a rich data structure that allows you to represent the exact XML contents in memory.
Regardless of the language used for expressions inside the JRXML, JasperReports creates a special Java class that
represents the whole report. The report is then compiled, instanced, and serialized in a JASPER file, ready for
loading at any time.
JasperReports' speedy operation is due to all of a report’s formulas being compiled into Java-native bytecode and
the report structure being verified during compilation instead of at run time. The JASPER file contains no
extraneous resources, such as images used in the report, resource bundles to run the report in different languages,
or extra scriptlets and external style definitions. All these resources must be provided by the host application and
located at run time.
Figure A-1 Data Source and Parameter Flows for Report Creation
JRDataSource allows a set of records organized in tables (rows and columns) to be read. It enables JasperReports
to fill a report with data from an explicit data source, using a JDBC connection (already instanced and opened) to
whichever relational database you want to run an SQL query on (which is specified in the report).
If the data don't meet your requirements, you may need to specify values to condition the report’s execution; you
can create name/value pairs to pass to the print engine. These pairs are named parameters, and they have to be
preventatively declared in the report. Through fillManager, you can join a JASPER file and a data source in a
JasperPrint object. This object is a meta-print that can create a real print after you export it in the format of your
choice through appropriate classes that implement the JRExporter interface.
JasperReports give you pre-defined exporters, such as those for creating files formatted as PDF, XLSX, CVS,
XML, RTF, ODF, text, HTML and SWF. Through the JRViewer class, you can view the print directly on the
screen and print a hard copy.
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.export.*;
import java.util.*;
public class JasperTest
{
public static void main(String[] args)
{
String fileName = "/devel/examples/test.jasper";
exporter.setParameter(
JRExporterParameter.OUTPUT_FILE_NAME,
outFileName);
exporter.setParameter(
JRExporterParameter.JASPER_PRINT,print);
exporter.exportReport();
System.out.println("Created file: " + outFileName);
}
catch (JRException e)
{
e.printStackTrace();
System.exit(1);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
}
}
Audit Domains
A Domain that accesses audit data in the repository and lets administrators create Ad Hoc reports of server activity.
There is one Domain for current audit logs and one for archived logs.
Audit Logging
When auditing is enabled, audit logging is the active recording of who used JasperReports Server to do what when.
The system installer can configure what activities to log, the amount of detail gathered, and when to archive the
data. Audit logs are stored in the same private database that JasperReports Server uses to store the repository, but
the data is only accessible through the audit Domains.
Auditing
A feature of JasperReports Server Enterprise edition that records all server activity and allows administrators to
view the data.
Calculated Field
In an Ad Hoc view or a Domain, a field whose value is calculated from a user-defined formula that may include
any number of fields, operators, and constants. For Domains, a calculated field becomes one of the items to which
the Domain's security file and locale bundles can apply. There are more functions available for Ad Hoc view
calculations than for Domains.
CloudFormation (CF)
Amazon Web Services CloudFormation gives developers and systems administrators an easy way to create and
manage a collection of related AWS resources, provisioning, and updating them in an orderly and predictable
fashion.
CRM
Customer Relationship Management. The practice of managing every facet of a company's interactions with its
clientele. CRM applications help businesses track and support their customers.
CrossJoin
An MDX function that combines two or more dimensions into a single axis (column or row).
Cube
The basis of most OLAP applications, a cube is a data structure that contains three or more dimensions that
categorize the cube's quantitative data. When you navigate the data displayed in an OLAP view, you are exploring
a cube.
Custom Field
In the Ad Hoc Editor, a field that is created through menu items as a simple function of one or two available fields,
including other custom fields. When a custom field becomes too complex or needs to be used in many reports, it is
best to define it as a calculated field in a Domain.
Dashboard
A collection of reports, input controls, graphics, labels, and web content displayed in a single, integrated view.
Dashboards often present a high level view of your data, but input controls can parametrize the data to display. For
example, you can narrow down the data to a specific date range. Embedded web content, such as other web-based
applications or maps, make dashboards more interactive and functional.
Dashlet
An element in a dashboard. Dashlets are defined by editable properties that vary depending on the dashlet type.
Types of dashlet include reports, text elements, filters, and external web content.
Data Island
A single join tree or a table without joins in a Domain. A Domain may contain several data islands, but when
creating an Ad Hoc view from a Domain, you can only select one of them to be available in the view.
Data Policy
In JasperReports Server, a setting that determines how the server processes and caches data used by Ad Hoc
reports. Select your data policies by clicking Manage > Server > Settings Ad Hoc Settings. By default, this
setting is only available to the superuser account.
Data Source
Defines the connection properties that JasperReports Server needs to access data. The server transmits queries to
data sources and obtains datasets in return for use in filling reports and previewing Ad Hoc reports. JasperReports
Server supports JDBC, JNDI, and Bean data sources; custom data sources can be defined as well.
Dataset
A collection of data arranged in columns and rows. Datasets are equivalent to relational results sets and the
JRDataSource type in the JasperReports Library.
Datatype
In JasperReports Server, a datatype is used to characterize a value entered through an input control. A datatype
must be of type text, number, date, or date-time. It can include constraints on the value of the input, for example
maximum and minimum values. As such, a datatype in JasperReports Server is more structured than a datatype in
most programming languages.
Denormalize
A process for creating table joins that speeds up data retrieval at the cost of having duplicate row values between
some columns.
Derived Table
In a Domain, a derived table is defined by an additional query whose result becomes another set of items available
in the Domain. For example, with a JDBC data source, you can write an SQL query that includes complex
functions for selecting data. You can use the items in a derived table for other operations on the Domain, such as
joining tables, defining a calculated field, or filtering. The items in a derived table can also be referenced in the
Domain's security file and locale bundles.
Dice
An OLAP operation to select columns.
Dimension
A categorization of the data in a cube. For example, a cube that stores data about sales figures might include
dimensions such as time, product, region, and customer's industry.
Domain
A virtual view of a data source that presents the data in business terms, allows for localization, and provides data-
level security. A Domain is not a view of the database in relational terms, but it implements the same functionality
within JasperReports Server. The design of a Domain specifies tables in the database, join clauses, calculated
fields, display names, and default properties, all of which define items and sets of items for creating Ad Hoc
reports.
Domain Topic
A Topic that is created from a Domain by the Data Chooser. A Domain Topic is based on the data source and
items in a Domain, but it allows further filtering, user input, and selection of items. Unlike a JRXML-based Topic,
a Domain Topic can be edited in JasperReports Server by users with the appropriate permissions.
Drill
To click on an element of an OLAP view to change the data that is displayed:
• Drill down. An OLAP operation that exposes more detailed information down the hierarchy levels by delving
deeper into the hierarchy and updating the contents of the navigation table.
• Drill through. An OLAP operation that displays detailed transactional data for a given aggregate measure.
Click a fact to open a new table beneath the main navigation table; the new table displays the low-level data
that constitutes the data that was clicked.
• Drill up. An OLAP operation for returning the parent hierarchy level to view to summary information.
Eclipse
An open source Integrated Development Environment (IDE) for Java and other programming languages, such as
C/C++.
ETL
Extract, Transform, Load. A process that retrieves data from transactional systems, and filters and aggregates the
data to create a multidimensional database. Generally, ETL prepares the database that your reports will access. The
Jaspersoft ETL product lets you define and schedule ETL processes.
Fact
The specific value or aggregate value of a measure for a particular member of a dimension. Facts are typically
numeric.
Field
A field is equivalent to a column in the relational database model. Fields originate in the structure of the data
source, but you may define calculated fields in a Domain or custom fields in the Ad Hoc Editor. Any type of field,
along with its display name and default formatting properties, is called an item and may be used in the Ad Hoc
Editor.
Frame
In Jaspersoft Studio, a frame is a rectangular element that can contain other elements and optionally draw a border
around them. Elements inside a frame are positioned relative to the frame, not to the band, and when you move a
frame, all the elements contained in the frame move together. A frame automatically stretches to fit its contents.
Group
In a report, a group is a set of data rows that have an identical value in a designated field.
• In a table, the value appears in a header and footer around the rows of the group, while the other fields appear
as columns.
• In a chart, the field chosen to define the group becomes the independent variable on the X axis, while the other
fields of each group are used to compute the dependent value on the Y axis.
Hierarchy Level
In an OLAP cube, a member of a dimension containing a group of members.
Input Control
A button, check box, drop-down list, text field, or calendar icon that allows users to enter a value when running a
report or viewing a dashboard that accepts input parameters. For JRXML reports, input controls and their
associated datatypes must be defined as repository objects and explicitly associated with the report. For Domain-
based reports that prompt for filter values, the input controls are defined internally. When either type of report is
used in a dashboard, its input controls are available to be added as special content.
Item
When designing a Domain or creating a Topic based on a Domain, an item is the representation of a database field
or a calculated field along with its display name and formatting properties defined in the Domain. Items can be
grouped in sets and are available for use in the creation of Ad Hoc reports.
JasperReport
A combination of a report template and data that produces a complex document for viewing, printing, or archiving
information. In the server, a JasperReport references other resources in the repository:
• The report template (in the form of a JRXML file)
• Information about the data source that supplies data for the report
• Any additional resources, such as images, fonts, and resource bundles referenced by the report template.
The collection of all the resources that are referenced in a JasperReport is sometimes called a report unit. End users
usually see and interact with a JasperReport as a single resource in the repository, but report creators must define
all of the components in the report unit.
JasperReports IO
An HTTP-based reporting service for JasperReports Library that provides a REST API for running, exporting, and
interacting with reports and a JavaScript API for embedding reports and their input controls into your web pages
and web applications.
JasperReports Library
An embeddable, open source, Java API for generating a report, filling it with current data, drawing charts and
tables, and exporting to any standard format (HTML, PDF, Excel, CSV, and others). JasperReports processes
reports defined in JRXML, an open XML format that allows the report to contain expressions and logic to control
report output based on run-time data.
JasperReports Server
A commercial open source, server-based application that calls the JasperReports Library to generate and share
reports securely. JasperReports Server authenticates users and lets them upload, run, view, schedule, and send
reports from a web browser. Commercial versions provide metadata layers, interactive report and dashboard
creation, and enterprise features such as organizations and auditing.
Jaspersoft Studio
A commercial open source tool for graphically designing reports that leverage all features of the JasperReports
Library. Jaspersoft Studio lets you drag and drop fields, charts, and sub-reports onto a canvas, and also define
parameters or expressions for each object to create pixel-perfect reports. You can generate the JRXML of the report
directly in Jaspersoft Studio, or upload it to JasperReports Server. Jaspersoft Studio is implemented in Eclipse.
Jaspersoft ETL
A graphical tool for designing and implementing your data extraction, transforming, and loading (ETL) tasks. It
provides hundreds of data source connectors to extract data from many relational and non-relational systems. Then,
it schedules and performs data aggregation and integration into data marts or data warehouses that you use for
reporting.
Jaspersoft OLAP
A relational OLAP server integrated into JasperReports Server that performs data analysis with MDX queries. The
product includes query builders and visualization clients that help users explore and make sense of
multidimensional data. Jaspersoft OLAP also supports XML/A connections to remote servers.
JavaBean
A reusable Java component that can be dropped into an application container to provide standard functionality.
JDBC
Java Database Connectivity. A standard interface that Java applications use to access databases.
JNDI
Java Naming and Directory Interface. A standard interface that Java applications use to access naming and
directory services.
Join Tree
In Domains, a collection of joined tables from the actual data source. A join is the relational operation that
associates the rows of one table with the rows of another table based on a common value in given field of each
table. Only the fields in a same join tree or calculated from the fields in a same join tree may appear together in a
report.
JPivot
An open source graphical user interface for OLAP operations. For more information, visit
http://jpivot.sourceforge.net/.
JRXML
An XML file format for saving and sharing reports created for the JasperReports Library and the applications that
use it, such as Jaspersoft Studio and JasperReports Server. JRXML is an open format that uses the XML standard
to define precisely all the structure and configuration of a report.
Level
Specifies the scope of an aggregate function in an Ad Hoc view. Level values include Current (not available for
PercentOf), ColumnGroup, ColumnTotal, RowGroup, RowTotal, Total.
MDX
Multidimensional Expression Language. A language for querying multidimensional objects, such as OLAP (On
Line Analytical Processing) cubes, and returning cube data for analytical processing. An MDX query is the query
that determines the data displayed in an OLAP view.
Measure
Depending on the context:
• In a report, a formula that calculates the values displayed in a table's columns, a crosstab's data values, or a
chart's dependent variable (such as the slices in a pie).
• In an OLAP view, a formula that calculates the facts that constitute the quantitative data in a cube.
Mondrian
A Java-based, open source multidimensional database application.
Mondrian Connection
An OLAP client connection that consists of an OLAP schema and a data source. OLAP client connections populate
OLAP views.
Parameter
Named values that are passed to the engine at report-filling time to control the data returned or the appearance and
formatting of the report. A report parameter is defined by its name and type. In JasperReports Server, parameters
can be mapped to input controls that users can interact with.
Pivot
To rotate a crosstab such that its row groups become column groups and its column groups become rows. In the Ad
in the repository. Administrators set user and role-based access permissions on repository resources to establish a
security policy.
Role
A security feature of JasperReports Server. Administrators create named roles, assign them to user accounts, and
then set access permissions to repository objects based on those roles. Certain roles also determine what
functionality and menu options are displayed to users in the JasperReports Server interface.
S3 Bucket
Cloud storage system for Amazon Web Services. JasperReports IO can use an S3 bucket to store files for its
repository.
Schema
A logical model that determines how data is stored. For example, the schema in a relational database is a
description of the relationships between tables, views, and indexes. In Jaspersoft OLAP, an OLAP schema is the
logical model of the data that appears in an OLAP view; they are uploaded to the repository as resources. For
Domains, schemas are represented in XML design files.
Schema Workbench
A graphical tool for easily designing OLAP schemas, data security schemas, and MDX queries. The resulting cube
and query definitions can then be used in Jaspersoft OLAP to perform simple but powerful analysis of large
quantities of multi-dimensional data stored in standard RDBMS systems.
Set
In Domains and Domain Topics, a named collection of items grouped together for ease of use in the Ad Hoc
Editor. A set can be based on the fields in a table or entirely defined by the Domain creator, but all items in a set
must originate in the same join tree. The order of items in a set is preserved.
Slice
An OLAP operation for filtering data rows.
SQL
Structured Query Language. A standard language used to access and manipulate data and schemas in a relational
database.
Stack
A collection of Amazon Web Services resources you create and delete as a single unit.
System Admin
Also called the system administrator. A user who has unlimited access to manage all organizations, users, roles,
repository permissions, and repository objects across the entire JasperReports Server instance. The system admin
can create root-level organizations and manage all server settings. The default system admin is the superuser
account.
Topic
A JRXML file created externally and uploaded to JasperReports Server as a basis for Ad Hoc reports. Topics are
created by business analysts to specify a data source and a list of fields with which business users can create reports
in the Ad Hoc Editor. Topics are stored in the Ad Hoc Components folder of the repository and displayed when a
user launches the Ad Hoc Editor.
Transactional Data
Data that describe measurable aspects of an event, such as a retail transaction, relevant to your business.
Transactional data are often stored in relational databases, with one row for each event and a table column or field
for each measure.
User
Depending on the context:
• A person who interacts with JasperReports Server through the web interface. There are generally three
categories of users: administrators who install and configure JasperReports Server, database experts or business
analysts who create data sources and Domains, and business users who create and view reports and
dashboards.
• A user account that has an ID and password to enforce authentication. Both people and API calls accessing the
server must provide the ID and password of a valid user account. Roles are assigned to user accounts to
determine access to objects in the repository.
View
Several meanings pertain to JasperReports Server:
• An Ad Hoc view. See Ad Hoc View.
• An OLAP view. See OLAP View.
• A database view. See http://en.wikipedia.org/wiki/View_%28database%29.
Virtual Data Source
A virtual data source allows you to combine data residing in multiple JDBC and/or JNDI data sources into a single
data source that can query the combined data. Once you have created a virtual data source, you create Domains that
join tables across the data sources to define the relationships between the data sources.
WCF
Web Component Framework. A low-level GUI component of JPivot. For more information, see
http://jpivot.sourceforge.net/wcf/index.html.
Web Services
A SOAP (Simple Object Access Protocol) API that enables applications to access certain features of JasperReports
Server. The features include repository, scheduling and user administration tasks.
XML
eXtensible Markup language. A standard for defining, transferring, and interpreting data for use across any number
of XML-enabled applications.
XML/A
XML for Analysis. An XML standard that uses Simple Object Access protocol (SOAP) to access remote data
sources. For more information, see http://www.xmla.org/.
XML/A Connection
A type of OLAP client connection that consists of Simple Object Access Protocol (SOAP) definitions used to
access data on a remote server. OLAP client connections populate OLAP views.
. classpath 152
cleaning cached data 480
.ini file 480-481
columns
A column groups 294, 296-297
in Table component 294, 296
Ad Hoc views
configuration
localizing 227
cleaning cached data 480
resources 227
for JasperReports IO 254
adding resources to the server 228
connections
advanced properties 56
creating 150
anchors 72
Google BigQuery 161
B importing from a workspace 19
bands JasperReports Server See JasperReports Server
advanced properties 56 JDBC 150
Beans See Java MongoDB 156
bookmarks 72 containers
grid layout 49
C creating
chart reports HTML5 charts 325, 333
theme for 230 report templates for JasperReports Server 222
charts crosstabs
combination charts 352 adding a measure 389
datasets 299 adding a row group 385
dual-axis charts 352 creating 376
multi-axis charts 352 crosstab parameters 382, 391
scatter charts 348 crosstab total variables 388
themes 308 custom calcuation 388
three-dimensional pie 299 datasets 377
types 299 defined 375
ClassNotFound error 152 editing group expressions 383
measures 387
F H
fields hardware requirements 15
adding to reports 28 HTML5 charts
CLOB 121 hyperlinks 359
discovering 200 HTML5 charts
double 122 advanced configuration 348
filtering 155 advanced formatting 367
in Dataset and Query dialog 198 advanced formatting example 345
in Groovy expressions 122 advanced settings 369
in Java expressions 122 area 324
in SQL queries 82 area spline 324
Java types vs. SQL types 154 available chart types 317
null 42, 122 bar 324
properties 82 column 324
sorting 155 column-line charts 352
units of measure in 478 column-spline charts 352
filter expressions 264 creating 325
filtering fields 155 disabling chart types options 369
folders formatting 330
repository 228 hyperlinks 332
workspace 17 hyperlinks to report units 365
font extensions 125 line 324
creating 132 multi-axis charts 352
using in a report 137 multi-axis column charts 352
fonts multi-axis line charts 352
excluding scripts in font sets 131 multi-axis spline charts 352
extensions 125 overview 317
font mappings 129 pie chart 333
font sets 131 preview in HTML5 Chart Edit Dialog 327
for PDF files 125 scatter charts 348
Unicode 121 spider column 324
uploading to JasperReports Server 140 spider line 324
using font extensions 137 spline 324
stacked area 324
G
stacked area-spline 324
GeoAnalytics 413 stacked bar 324
getFieldValue 189 stacked column 324
grid layout 49 stacked column-line charts 352
Groovy 117 stacked column-spline charts 352
groups stacked line 324
column groups 294, 296-297 stacked percent area 324
creating 460 stacked percent area-spline 324
Group Band 36, 460 stacked percent bar 324
Group Footer 37, 458 stacked percent column 324
Group Header 37, 458 stacked percent line 324
P queries
fields 154
page format 37 MongoDB 158
palette 46 results 155
parameter set 107 specifying 154
parameters SQL 154
adding and deleting 93
layout 296
table styles 291
Test button 153
text See fonts
themes 308
themes, for charts 230
TIBCO Spotfire Information Links 191
time fields
in crosstabs 378
Topics 226
field names in 227
localization 227
trust store 210
U
Unicode 121
W
workspace
importing projects 17
upgrading 17
X
XML
data sources 164
report file 489
XML/A 171
XPath 164, 168