iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library

13.07.2015 Views

iReport Ultimate GuideFigure 15-6Dataset Run definition for a chartFigure 15-6 shows a dataset run for a chart. The dataset run definition is similar to what you use to set up a subreport element.A subreport itself can be seen as a subdataset, and you need to set values for its parameters and specify a connection to use inorder to get the data. You can set the value of the subdataset parameters using expressions containing main report objects (likefields, variables, and parameters), define a parameters map to set values for the subdataset parameters at run time, and definethe connection or data source that will be used by the subdataset.15.3 Working Through an Example SubdatasetThe following step-by-step example shows how to use a subdataset to fill a chart.:1. Create a basic report using a simple SQL query:(select count(*) as tot_orders from orders)The resulting main report will have just a single record containing the total number of orders (see Figure 15-7).302

SubdatasetsFigure 15-7Initial layout2. Create a subdataset as explained above in this chapter (15.1, “Creating a Subdataset,” on page 299). Edit the subdatasetquery and set it to:select SHIPCOUNTRY, COUNT(*) country_orders from ORDERS group by SHIPCOUNTRYThe fields will be registered in the subdataset (see Figure 15-8).Figure 15-8The subdataset to fill the chart3. Now create a chart element in the title, for instance, a Pie 3D (like in Figure 15-9). Right-click the chart and select thechart data menu item to open the chart definition dialog.Figure 15-9The subdataset will be used to fill the chart303

SubdatasetsFigure 15-7Initial layout2. Create a subdataset as explained above in this chapter (15.1, “Creating a Subdataset,” on page 299). Edit the subdatasetquery and set it to:select SHIPCOUNTRY, COUNT(*) country_orders from ORDERS group by SHIPCOUNTRYThe fields will be registered in the subdataset (see Figure 15-8).Figure 15-8The subdataset to fill the chart3. Now create a chart element in the title, for instance, a Pie 3D (like in Figure 15-9). Right-click the chart and select thechart data menu item to open the chart definition dialog.Figure 15-9The subdataset will be used to fill the chart303

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!