ishanisamaraweera Posted June 12, 2018 Share Posted June 12, 2018 I have added a jar file to add a chart customizer class in my jasper report. But when compiling it gives the NoSuchMethodError. I have added enough libraries to the classpath and I am using jasperreports-6.5.1 and jfreechart-1.5.0.Jasper exception:java.lang.NoSuchMethodError: org.jfree.chart.title.LegendTitle.setItemLabelPadding(Lorg/jfree/chart/ui/RectangleInsets;)V null java.lang.NoSuchMethodError: org.jfree.chart.title.LegendTitle.setItemLabelPadding(Lorg/jfree/chart/ui/RectangleInsets;)VSource code in the jar file:public class ChartCustomizer extends JRAbstractChartCustomizer {DecimalFormat twoPlaces = new DecimalFormat("0.00");@Overridepublic void customize(JFreeChart jFreeChart, JRChart jrChart) { if (jFreeChart.getPlot().getClass().equals(PiePlot3D.class)) { formatPiePlot3D((PiePlot3D) jFreeChart.getPlot()); } else if (jFreeChart.getPlot().getClass().equals(PiePlot.class)) { formatPiePlot((PiePlot) jFreeChart.getPlot()); } LegendTitle legend = jFreeChart.getLegend(); legend.setItemLabelPadding(new RectangleInsets(2, 2, 2, 999999999));}private void formatPiePlot3D(PiePlot3D plot) { PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{2}", new DecimalFormat("0"), new DecimalFormat("0.00%")); PieSectionLabelGenerator legendGenerator = new StandardPieSectionLabelGenerator("{0} - {1}", new DecimalFormat("#,##0.00", new DecimalFormatSymbols(new Locale("en_US"))), new DecimalFormat("0%")); plot.setLegendLabelGenerator(legendGenerator); plot.setLabelGenerator(labelGenerator);}private void formatPiePlot(PiePlot plot) { PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{2}", new DecimalFormat("0"), new DecimalFormat("0.00%")); PieSectionLabelGenerator legendGenerator = new StandardPieSectionLabelGenerator("{0} - {1}", new DecimalFormat("#,##0.00", new DecimalFormatSymbols(new Locale("en_US"))), new DecimalFormat("0%")); plot.setLegendLabelGenerator(legendGenerator); plot.setLabelGenerator(labelGenerator);} }[/code]Libraries imported to the jar file source and classpath:jcommon-1.0.24 jfreechart-1.5.0 jasperreports-6.5.1 jfreesvg-3.3 Link to comment Share on other sites More sharing options...
szaharia Posted June 12, 2018 Share Posted June 12, 2018 Use JFreeChart v. 1.0.19 instead of 1.5.0Some packages were moved/renamed in 1.5.0: https://github.com/jfree/jfreechart/blob/master/README.md#migration-from-jfreechart-10x Link to comment Share on other sites More sharing options...
patrick_s Posted June 4, 2019 Share Posted June 4, 2019 Is there any plan to update jasper to support JFreeChart 1.5 ? Link to comment Share on other sites More sharing options...
davidgarratt Posted April 26, 2020 Share Posted April 26, 2020 I have the same problem - I just JFreeChart 1.5 for an on-screen graph but after spending a long time creating a jasper report with a pie chart I find I can only run it within Eclipse and not within my application as I'm using 1.5 and not 1.019 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now