0

我想显示一个饼图。我想要达到的结果:

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...
4

1 回答 1

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( )**
于 2013-03-01T07:03:49.590 回答