The Data Key Property
Similar to Tables in reporting, all charts must first be assigned a Data Key. This assignment configures the chart to look at specific keys in a data source, and prevents any name collisions with other data keys: if multiple data sources in your report return a column named "id", the chart wouldn't know which column you were referring to without this initial assignment. Like all keys in the Report manual, make sure your Domain and Range keys are just the column name. If your keys look like "query.column" then you will not see data in your chart.
Assignment can be achieved by drag-and-dropping a key into the Data Key property, or by clicking the Key Searchbutton.
Once assigned, you can the start adding pens or bars to your chart.
To use the chart, drag the component from the Report Palette to your report. Type or drag a data key from the Key Browser into the Data Key field of the Chart Options tab in the Property Inspector. Select a time series domain (for example a
t_series column of your query). The Y axis (value) can be modified in the Chart Options tab, but the X axis (time range) is based on the data in the 'Data Key' that powers the chart dataset.
To add pens to your query, simply click the
Chart Options area
Pen Configuration area
To use the chart, drag the component from the Report Palette to your report. Type or drag a data key from the Key Browser into the Data Key field of the Chart Options tab. Select Domain Key to use for the X axis.
To add pens to your query, simply click thebutton on the Chart Options tab next to the Pens table in the Property Inspector. You can either double click, or select a pen and click the button on the right, to navigate to the Pen Configuration area. Click the to return to the Chart Options tab. The setup and Configuration of this chart and its pens works similarly to the Timeseries Chart, the difference being that instead of using a date datatype for the domain, a different datatype is needed.
To create a Bar Chart, simply drag the component from the Report Palette and drop it onto your report. Bar Charts are quite easy to use and have a large number of customization options. Configuring a Bar Chart requires a data source whose first column generally contains the name or identifier the bar represents, and the following one or more columns represent some numerical value to be plotted. A Bar Chart example can be found in the Report Workflow Tutorial.
To create a new Pie Chart, drag the pie chart palette item from the Report Design Palette onto your Report Page or Parent Shape. A pie chart has a simple configuration consisting of label values (generally Strings) and numeric quantity values. Color segments can be added or removed by clicking thebutton on the Configure tab.
The Pie Chart in the images above was created using a simple data source which had just two columns, the first which represented our Label, and the second being a column of values.
Fruits, Amount "Bananas", 52 "Grapes", 154 "Apples", 58 "Pineapples", 25 "Other", 265
The look and feel of the Timeseries, XY, and Bar charts may be modified through scripting. Scripting may be accessed on these charts by selecting them, and then clicking the Edit Script icon in the Property Inspector. Note that the Enabled property must be checked for the script to become active.
Clicking on Edit Script will provide access to configureChart, which allows you to make modifications to the chart right before the report is rendered. The charts are simply JFreeCharts, so reading through the JFreeChart API would be useful here.