Chart Themes

Another way to customize graphs is by creating a chart theme, which gives you full control over the style of the chart. Chart themes allow you to customize the design of a chart. Chart themes are reusable: you can use the same chart theme in many reports to have a unified appearance. You can also update a chart theme to modify the appearance across all reports. As of the current release, Jaspersoft Studio is the supported tool for creating chart themes.

To create a JasperReports chart theme:

1. Select File > New > Other.

The Select a wizard window opens.

2. Select the Chart Themes wizard. Click Next.

The New Chart Theme wizard opens.

 

3. Select the file in which you want to store your theme, and name it. The file needs to have the extension .jrctx.

Click Finish. The Chart Theme Designer opens.

Using the Chart Theme Designer

JasperReports organizes a chart theme into seven sub-sections, visible in the Outline view.

Chart Theme Designer Outline View

Chart: Set properties for borders, color, background, and padding.
Title: Set properties for position, color, alignment, padding, and font.
Subtitle: Set properties for position, color, alignment, padding, and font. These can be set to INHERITED on the Advanced tab.
Legend: Set whether or not to show a legend, and if so, set position, alignment, colors, frame, and font.
Plot: Set properties for label rotation, foreground, orientation, colors, image alignment, padding, grid lines, chart outline, series stroke and colors, and display and tick label fonts.
Domain Axis: Set properties, color, and visibility for line, tick count, tick mark, tick label, tick padding, and tick label font. Set properties, color, and visibility for label, label padding, and label font.
Range Axis: Set properties, color, and visibility for line, tick count, tick mark, tick label, tick padding, and tick label font. Set properties, color, and visibility for label, label padding, and label font.

Any properties you set are applied to all chart types. If you want to see one of the chart types in close up, click on that chart. Click on the close up view of the chart to return to viewing all charts.

Editing Chart Theme XML

You can see and edit the chart theme XML from the Source tab. However, the XML appears as one long line. It is better to copy-and-paste it into the text editor of your choice and edit it there.

Creating a JasperReports Extension for a Chart Theme

The JRCTX file cannot be used in a report until it is wrapped into a JasperReports extension JAR file.

To export the theme as a JAR:

1. From the Preview tab, click the button.

The Save As window opens.

Save As JAR

2. Enter or select the parent folder, name the file, and name your theme. Click OK.

A dialog appears, indicating that the Chart Theme was generated.

Applying a Chart Theme

After you create a chart theme, you want to be able to see it in the list of themes. For that to happen, add the theme to your classpath.

Your theme is now available in the list of themes.

Version: 
Feedback