I new with JFreeChart, I tried to used it in jasperreport, I have seen a question on how to insert a JFreechart object in jasperreport, and one of responses works, but the method used is deprecated:
JFreeChartRenderer jrc = new JFreeChartRenderer( SpiderChart.createChart2());
what is the new method to use ?
The direct substitution of JFreeChartRender is the DrawChartRendererImpl
new DrawChartRendererImpl(org.jfree.chart.JFreeChart chart, ChartHyperlinkProvider chartHyperlinkProvider);
another method is to provide an java.awt.image.BufferedImage, that you can retrive from JFreechart
BufferedImage bufferedImage = chart.createBufferedImage(width, height);
Note, however that the normally you included it directly in you jrxml (from IDE you can drag the chart component into the report)
Example of pie chart jrxml
<pieChart>
<chart>
<reportElement x="89" y="100" width="200" height="100" uuid="b96a1b13-4bf0-4983-8168-97b80abdae04"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<keyExpression><![CDATA[$F{fieldKey}]]></keyExpression>
<valueExpression><![CDATA[$F{fieldValue}]]></valueExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
These are the Standard chart types you can use, if you are using JasperSoft Studio (and similar in iReport) see Creating Charts and Datasets with Jaspersoft Studio
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With