我想显示一个饼图。我希望实现的结果:
Summary:
Sample Total
A1 10
A2 20
A3 30
我想将饼图显示为10
,20
,30
作为切片,A1
,A2
,A3
作为标签
在阅读并跟踪了一些示例后,我开始研究3D饼图,但我一直有以下异常:
Filling report...
Locale: English (United States)
Time zone: Default
Error filling print... java.lang.Long cannot be cast to java.lang.String
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at net.sf.jasperreports.charts.fill.JRFillPieSeries.evaluate(JRFillPieSeries.java:136)
at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:160)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:758)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:281)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:144)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:822)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:61)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745)
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:891)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
Print not filled. Try to use an EmptyDataSource...
答案 0 :(得分:0)
在Ireport打开饼图的“图表数据”并转到“部分值”选项卡,您必须提供三个表达式,它们是: -
1 :- Key Expression (column which includes A1,A2,A3 values)
2:- Value expression (Should be integer - column which includes 10,20,30))
3:- Label expression (Should be string )
- if you want to convert integer column to sting use this -
**$F{column which includes 10,20,30}.toString( )**