Ba Ma Posted February 18, 2016 Posted February 18, 2016 Hi there,i am trying to make a new Pie Chart. Everything worked out so far for different Charts, with Strings. Now I wanted to make an Pie chart with an Integer and this error occurs: net.sf.jasperreports.engine.JRException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Stringat com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:511)at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:486)at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:367)at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Stringat net.sf.jasperreports.charts.fill.JRFillPieSeries.evaluate(JRFillPieSeries.java:135)at net.sf.jasperreports.charts.fill.JRFillPieDataset.customEvaluate(JRFillPieDataset.java:198)at net.sf.jasperreports.engine.fill.JRFillElementDataset.evaluate(JRFillElementDataset.java:162)at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:187)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:742)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:262)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:122)at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:555)at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:119)at java.lang.Thread.run(Unknown Source) Im new to jaspersoft, so I don't really now how to handle this error. Could anyone help me out, please? Thank You Cheers Marco
Solution lucianc Posted February 18, 2016 Solution Posted February 18, 2016 The label expression in pie datasets is required to evaluate to Strings, and there is no automatic conversion from other types.If you want an integer to display as label, you can use $V{value}.toString() or TEXT($V{value}, "#,###.00") if you want a specific format.Regards,Lucian
Ba Ma Posted February 18, 2016 Author Posted February 18, 2016 Hi Lucian, Thank you very much for the rapid answer. It's working now! =) Cheers Marco
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