ak10 Posted January 6, 2011 Share Posted January 6, 2011 In my report I have a pie chart in which I want to display data according to a query result that has 2 fields: field_name, field_time. This pie chart should display the time for each name.field_name is of type java.lang.String and field_time is of type java.sql.TimeIn the pie chart I put ${field_name} as the key expression and ${field_time} as the value expression.when i compile I get an error ( see below).How can I create a pie chart t display this info? Error filling print... Error evaluating expression : Source text : $F{field_time} net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : $F{call_duration} at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:195) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:589) at net.sf.jasperreports.charts.fill.JRFillPieSeries.evaluate(JRFillPieSeries.java:135) at net.sf.jasperreports.charts.fill.JRFillPieDataset.customEvaluate(JRFillPieDataset.java:216) at net.sf.jasperreports.engine.fill.JRFillElementDataset.evaluate(JRFillElementDataset.java:164) at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:158) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:747) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:270) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247) at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:877) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '05:41:03' with class 'java.sql.Time' to class 'java.lang.Number' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToNumber(DefaultTypeTransformation.java:139) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:234) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:602) at Vigilance32Report32Template_1294329035048_573338.evaluate(calculator_Vigilance32Report32Template_1294329035048_573338:292) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:182) ... 16 more Thanks! Link to comment Share on other sites More sharing options...
cbarlow3 Posted January 6, 2011 Share Posted January 6, 2011 I'll leave the well-deserved disdain for pie charts to Stephen Few, but I have to admit that in this case I'm having problems even visualizing what information you're trying to convey. Let's say your query returns the following three rows:field_name field_timePearl Harbor Attack Dec 7, 1941 17:55:00 UTCApollo 11 Moon Landing Jul 20, 1969 20:17:00 UTC Current Time Jan 6, 2011 19:36:30 UTC what exactly do you expect these three pieces of pie to look like? How are those three TIMES (date/time stamps) going to be expressed as VALUES that can be compared to each other as parts of some whole? If those three times were DURATIONS (hours:minutes:seconds, for example) then you could convert them all to a standard unit like seconds or days or whatever and get a pie chart. But TIMES? I can't picture it at all.Carl Link to comment Share on other sites More sharing options...
ak10 Posted January 9, 2011 Author Share Posted January 9, 2011 The time I want to display is a DURATION, and it's type is java.lang.time.for example for each name, I would like to display the duration of the call they made.so the size of the slice in the pie chart would be according to the duration of the call the person made.The field is now in format: days hours:min:sec How can I display this in a pie chart? how do I convert the time? what is the best way to do this in order to get the most accurate result? Link to comment Share on other sites More sharing options...
cbarlow3 Posted January 10, 2011 Share Posted January 10, 2011 Well, it might depend on which flavor of SQL you're using, but I've been able to get date(), year(), time(), hour(), and minute() functions to work on a java.sql.Timestamp column. I don't think I have any fields in my database that are java.lang.Time, althlough the time() function in SQL seems to be converting my java.sql.Timestamp into a java.sql.Time. If you want the most accurate representation, I'd say convert each duration to seconds. For example, if it were just hours and minutes:select field_time, (3600*hour(field_time)+60*minute(field_time)+second(field_time)) as duration_in_secondsend Carl 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