All chart types can display a legend that explains the values represented by the chart. By
default all charts display the legend, but you can suppress this display by setting the
You can control the font-related properties as well as the text color and the background
color of the chart legend using the optional
tag and its nested
Although the JFreeChart library is a fairly complete charting package that offers great
flexibility and a comprehensive range of settings to fully customize the appearance and
the content of the charts it renders, the built-in chart component offered by JasperReports
exposes only a subset of the library’s original charting functionality. This ensures that
JasperReports charts are easily embeddable into reports and that the basic set of
properties exposed through JRXML and the object model is enough for the majority of
In time, other JFreeChart settings will be exposed through the built-in chart component,
but certainly JasperReports will never be able to expose all the JFreeChart settings
through JRXML tags or the API.
To provide full control over chart customization even when using the built-in chart
component, JasperReports can make use of either a chart theme implementation, or of a
chart customizer implementation associated with the chart element, or both.
Chart themes are a more recent addition to the library and in a way they deprecate the
chart customizers because they bring enhanced capabilities in controlling chart output.
A chart customizer is an implementation of the
interface that is associated
with the chart element using the
attribute. The easiest way to
implement this interface is by extending the
class and thus
having access to parameters, fields, and variables, for more flexible chart customization
based on report data.
However, we now encourage people to implement and work with chart themes instead of
chart customizers, because chart themes give more control over chart output, including
the creation of the JFreeChart object itself. Chart customizer only allow modifying the
JFreeChart object that is created externally and passed in to them. Also, chart themes
affect a whole range of chart types across multiple reports and are not necessarily tied to
a specific chart element within a report. They can even apply globally to all charts within
a given JasperReports deployment, applying a new look and feel to all charts created
within that environment.