I have a report with several subreports, some of which have graphs. I'm trying to implement a class to set a theme on this graphs, but i'm not seeing any changes. The class looks as follows:
package chartThemes; import java.awt.Color; import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.ValueAxis;import org.jfree.chart.plot.XYPlot; import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer; public class ChartThemeTest implements JRChartCustomizer { @Override public void customize(JFreeChart chart, JRChart jasperChart) { XYPlot plot=chart.getXYPlot(); ValueAxis rangeAxis=plot.getRangeAxis(); rangeAxis.setMinorTickCount(4); rangeAxis.setMinorTickMarkOutsideLength(1.0f); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setTickMarkOutsideLength(2.5f); jasperChart.setBackcolor(new Color(150, 20, 30)); jasperChart.setForecolor(new Color(204, 0, 0)); } }
I'm using iReport 5.6.0, and as far as I can see, it loads the .jar successfully (if I mess the class name in the properties editor of the graph in iReport, it gives an error while creating the chart). But when I compile and create the PDF, the chart has the same properties setted in the iReport, instead of the properties setted in the java class.
Any suggestion?
EDIT: I tried adding a title through chart.setTitle(<title>), and the title appeared in the final report, so I'm guessing that the class is being read, but i'm missing something to make the jasperChart changes to occur.