| JasperReports Ultimate Guide - Samples - Schema - Configuration - Functions - FAQ - API (Javadoc)
|
|
|
|
|
| JasperReports - Chart Customizers (version master-SNAPSHOT) | |
|
|
|
|
|
|
| Main Features in This Sample | |
|
| Multiple Chart Customizers |
|
|
|
| Secondary Features | |
| Charts | |
| Altering Charts (Chart Customizers) | |
|
|
|
||||
| top | |||||
|
|
|||||
![]() | Multiple Chart Customizers | Documented by Teodor Danciu | |||
|
|
|||||
|
| Description / Goal |
| How to make various changes to a generated chart using the JFreeChart API, using one or more chart customizer on the same report. | ||
|
| Since |
| 6.3.1 | ||
|
|
|||||
|
|
Multiple Chart Customizers
When the chart customizer feature was first introduced, only one chart customizer object could be assigned to a chart element using the customizerClass attribute of the chart element. Although a chart customizer gives great flexibility in altering or enhancing the output of the chart element, having only one such object did not allow easy reuse and piling/stacking up several chart customizer at a time. Support for multiple chart customizers per chart element was introduced using custom properties at chart element level having their names in the following format:
net.sf.jasperreports.customizer.class.{arbitrary_name}
Such a property is supposed to specify the name of a class that implements the
JRChartCustomizer interface and has an empty constructor.
This constructor is used to instantiate a chart customizer object at report fill time and is then called to customizer the chart output.
The {arbitrary_name} suffix of the property is optional and represents the name of the chart customizer. This value will be injected into
the chart customizer object using the setName(String) method in case the chart customizer implements the
NamedChartCustomizer interface.
The name of the chart customizer allows the chart object to identify additional custom properties at chart element level which are considered to be its own and help configure it, because they contain the name as part of the full property name which have the following format:
net.sf.jasperreports.customizer.{arbitrary_name}.{property_name}
Here follows an example in which the domain axis of an XY line chart is configured by setting the minimum and maximum values of the axis as well as the
distance between ticks:
<xyLineChart>
<chart evaluationTime="Report">
<reportElement x="0" y="0" width="555" height="300">
<property name="net.sf.jasperreports.customizer.class.domainAxis" value="net.sf.jasperreports.customizers.axis.DomainAxisCustomizer"/>
<property name="net.sf.jasperreports.customizer.domainAxis.minValue" value="60"/>
<property name="net.sf.jasperreports.customizer.domainAxis.maxValue" value="90"/>
<property name="net.sf.jasperreports.customizer.domainAxis.tickUnit" value="5"/>
</reportElement>
...
</chart>
...
</xyLineChart>
Packaged Chart Customizers
The chart customizers sample provides a series of chart customizer implementations that can be added as a separate JAR file to an application that uses the JasperReports library. These chart customizers leverage various features of the JFreeChart library and are as follows: Axis Configurations net.sf.jasperreports.customizers.axis.DomainAxisCustomizer net.sf.jasperreports.customizers.axis.RangeAxisCustomizer Chart Markers net.sf.jasperreports.customizers.marker.CategoryMarkerCustomizer net.sf.jasperreports.customizers.marker.DomainIntervalMarkerCustomizer net.sf.jasperreports.customizers.marker.DomainValueMarkerCustomizer net.sf.jasperreports.customizers.marker.RangeIntervalMarkerCustomizer net.sf.jasperreports.customizers.marker.RangeValueMarkerCustomizer Custom Shapes net.sf.jasperreports.customizers.shape.LegendShapeCustomizer net.sf.jasperreports.customizers.shape.LineDotShapeCustomizer Miscellaneous net.sf.jasperreports.customizers.LevelRenderCustomizer net.sf.jasperreports.customizers.SplineCustomizer net.sf.jasperreports.customizers.StepCustomizer More implementations will be added to this package in the future, but until then, you can leverage this feature and implement and use your own chart customizers. |
||||
|
|
|||||
|
|
| © 2001- Cloud Software Group, Inc. www.jaspersoft.com |