Charts in Reporting - Scripting
The most common configuration options for charts are found in the properties panel, but almost every part of a chart can be configured through scripting. To turn on configuration scripting in a chart, select the chart, scroll to the bottom of the Chart Options tab, enable scripting and click on Edit Script.
Example
Say we want to change the font used in a charts labels. We can use the following code:
Configure Chart
def
configureChart(chart):
# This configures the legend on a report chart to use a large, bold, monospaced font
from
java.awt
import
Font
legend
=
chart.getLegend()
# http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html
font
=
Font(Font.MONOSPACED, Font.BOLD,
48
)
# https://docs.oracle.com/javase/7/docs/api/java/awt/Font.html
legend.setItemFont(font)
# http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/title/LegendTitle.html
The above code would change the font used in the chart's legend to a 48 point bold monospaced font. The comments give links to the APIs used in each line of the code.
On this page...