|
|
||||||||
Project Home |
Tracker |
Documents |
Tasks |
Source Code |
Discussions |
Reports |
File Releases |
Wiki |
Project Admin |
|||||||||||||
| wiki1122: Charts |
iReport DocumentationManual for iReport >= 0.2.0 (Pure Java version of iReport)8 Charts JasperReports does not directly manage charts; they must be created independently as images, even using one of numerous open-source Java libraries available to create charts. The image produced will be shown using an image element. The idea is really simple, but the creation of a chart at run time requires a good knowledge of JasperReports programming and many times one needs to write scriptlets capable of collecting data that will be exposed by the chart. With version 0.4.0, iReport provides a solution to simplify chart building with a new chart tool. This tool permits creation of a chart configuring main properties and data to feed it in a very simple manner for the final user. Creation of the chart is delegated to a well-known open-source library, JFreeCharts (http://www.jfree.org/jfreechart/). For now, iReport only supports a few chart types exposed from JFreeCharts and can only modify a few chart properties (in effect, JFreeChart permits really fine control of all chart properties), but it's possible to create clear charts with a big visual impact. 8.1 Creation of a Simple Chart In this paragraph, we'll take confidence with chart tool, building a report with a Pie3D chart step by step; subsequently we'll take a look at all details related to chart handling. select SHIPCOUNTRY, COUNT(*) AS ORDERS_COUNT from ORDERS group by SHIPCOUNTRY
Fig. 8.1 The report query The idea is to create a chart to illustrate sales in different states.
Fig. 8.2 The report with field HIPCOUNTRY We have to set the height of no useful bands (all exclude summary and details) to zero.
Fig. 8.3 We put the chart in the summary band. iReport will alert the need to activate the internal scriptlet support to handle scriptlet: click YES. From the chart palette select i.e.the Pie3D chart type and press OK. We should now be in the situation shown in figure 8.2.
The chart properties window (the same from which we choose the chart type, fig.8.5 ) will appear.
Fig. 8.5 Chart Type Tab This window is organized with three tabs: e: Chart type, Data and Chart details. The first tab permits choosing the chart type to show: every chart needs data structured in series; all series needed by the selected chart type are listed in the frame labeled "Chart Info" on tab bottom where the name of the chart type and the library used to generate it (for now all charts are produced using JFreeChart 0.9.21, but iReport can support other libraries) are exposed . In our case, we'll need a series to store labels (exposed in the Y axis), and a single serie of numbers (named Series 1).
Fig. 8.6 Tab Data There are different ways to create a series. For now, we'll use the simplest way; we'll let iReport handle the series for us. Select the "Report series" button to open the report series window (fig. 8.5).
Create a brand new series by pressing "New series". The window in fig. 8.8 will appear. Give a name for the series (i.e. COUNTRY) and set the "Reset When" to . Now we have to write an expression for the value that we want collect to generate the series. In our case, we'll have a series of strings for SHIPCOUNTRY and a series of integer numbers for Series1.
Fig 8.8 Series definition To use the expression editor, press the left mouse button over the text area and select the "Use texteditor" menu item.
Fig 8.9 The final report with the chart On iReport Guide: Series: Automatic Series, Custom series Chart Types: Pie Chart, Pie3D Chart, Bar, Bar3D, Line, Area |
|
|