JulEgner Posted August 10, 2006 Share Posted August 10, 2006 Is it possible to use return Values of a Subreport for generating a chart?I have a Subreport in the detail Area that returns a number. I want to use these Numbers, generated in each detail Area, in a Chart.Do you know if this is possible? Link to comment Share on other sites More sharing options...
lucianc Posted August 10, 2006 Share Posted August 10, 2006 Unfortunately this is not easily achievable. The moment at which chart datasets get increment and the moment at which values are returned from the subreport cannot be arranged in a convenient sequence. More precisely, chart datasets are incremented after a new row is retrieved from the data source and the variables are calculated, but before the band gets rendered, and values are returned from subreports while the band gets rendered. Because of this, the value returned from the subreport is not available when the dataset gets incremented. The similar problem of displaying values returned from subreports inside the same band was solved by introducing the "Band" evaluation time for text fields. Maybe something similar can be done for the chart dataset increment type, but this needs more investigation. Creating charts out of values returned from subreport is still possible using the image renderer approach (collect the values in the scriptlet and create an image renderer by directly using the JFreeChart APIs), but this requires some effort to achieve. Regards,Lucian Link to comment Share on other sites More sharing options...
JulEgner Posted August 15, 2006 Author Share Posted August 15, 2006 I changed the Database from Access to mySQL and now the Charts do display something. The XY-chart displays the number of Telephone lines per hour and the Time-Chart displays only a dot at 00:00:00 and 0..but i would like to have a chart of time and the used telephone lines per minute. The X-Value is calculated by: new Double((new Double(0).valueOf($F{Uhrzeit}.substring(0,2))).doubleValue()+(new Double(new Integer($F{Uhrzeit}.substring(3,5)).intValue()/60)).doubleValue()) $F{Uhrzeit} is the time as a String in Format '23:59'. the Y-Value is just the number of Lines (Integer). This Chart displays the number of Lines per hour, but should display per minute. The Times Series Dataset seems to display a null-value. It gets its time-value from this:new SimpleDateFormat("HH:mm").parse($F{Uhrzeit}) Both charts have Reset Type="Report" and Increment when expression = "new Boolean(true)" Do you have any ideas? Link to comment Share on other sites More sharing options...
JulEgner Posted August 15, 2006 Author Share Posted August 15, 2006 Ok, its working.I changed the x-values to new Double((new Double(0).valueOf($F{Uhrzeit}.substring(0,2))).doubleValue()+new Double(new Double(new Integer($F{Uhrzeit}.substring(3,5)).intValue()).doubleValue()/60.0).doubleValue()) and get Minutes. I still do not know how to get the time-chart working, but thats not urgent anymore. Thanks for your help! Link to comment Share on other sites More sharing options...
midrag Posted November 8, 2006 Share Posted November 8, 2006 Hi, back to the topic: i use a bean as datasource (= for example a project) which has other beans as attributes (for example a statement from a usergroup). Now i have to filter the statements (for example 3 States: good, normal, bad) and chart for each project the amount of the states of each usergroup. As mentioned here i can actually Chart from Variables passed from a Subreport to my Masterreport. The Problem is the evaluation time -> The Values i get are not matching the Values i expected (actually they are just shifted by one "Report Row"). If i want them to be displayed correctly in the detail band i must set the evaluation time to "band" in the Property of the Textfield the Variable is displayed with. unfortunatly i can't set the evaluation time within the Value-Expression of the Chart-data. I know that this Bug is closed (see: http://jasperforge.org/sf/go/artf1533?nav=1). I have other use cases which are basicly relying on charting from returned values from subreports, so that it wouldn't be a solution to create a new (hardcoded) datasource. Can you give me some information on how i might fix this? thanks for your help in advance! best regards, midrag Link to comment Share on other sites More sharing options...
javydreamercsw Posted November 8, 2006 Share Posted November 8, 2006 I'm following your thread since I have an alike problem. Can you give an example of the bean or at least where I can see an example? Thanks Link to comment Share on other sites More sharing options...
midrag Posted November 9, 2006 Share Posted November 9, 2006 hi javydreamercsw, a simple example is described here (simply charting with the RECORD_COUNT Variable obtained from a Subreport). The Bean (actually an array of Beans) i mentioned above contains another array of Beans. My approach was to create a subreport with the array of Beans from the Datasource of my Masterreport as new Datasource for my Subreport.Hope this helps you. regards, midrag Link to comment Share on other sites More sharing options...
midrag Posted November 10, 2006 Share Posted November 10, 2006 should i enter a new Feature Request for this Problem? Link to comment Share on other sites More sharing options...
lucianc Posted November 10, 2006 Share Posted November 10, 2006 Yes, post a feature request for this. Regards,Lucian Link to comment Share on other sites More sharing options...
midrag Posted November 13, 2006 Share Posted November 13, 2006 Feature Request submitted. regards, midrag Link to comment Share on other sites More sharing options...
midrag Posted November 15, 2006 Share Posted November 15, 2006 I submitted a sample as well (here).I included Java Code for creating a proper DataSource (JRBeanArrayDataSource). Link to comment Share on other sites More sharing options...
javydreamercsw Posted November 15, 2006 Share Posted November 15, 2006 Thanks for the sample! Sadly I couldn't make it work. Do you mind sharing the Connection properties within iReport to set up the Data source? Settings:Name: BeanType: Custom JRDatasourceFactory Class: Dreamer.iReport.iReportBeanCollectorStatic Method: getDatasource Name Note: I made some class name changes (BeanSample->iReportBeanCollector) and the Dreamer.iReport is the package/location in the jar I added to iReport classpath in order to see the class.Post edited by: javydreamercsw, at: 2006/11/15 14:27 Link to comment Share on other sites More sharing options...
midrag Posted November 15, 2006 Share Posted November 15, 2006 hi dreamer, I used it directly in my application, so i didnt check if it worked with iReport.I updated the uploaded sample to work with ireport (use include jar in classpath). I posted instruction with the updated sample.Let me know if you get it to run. regards, midragPost edited by: midrag, at: 2006/11/15 15:34 Link to comment Share on other sites More sharing options...
gootjemar Posted December 20, 2012 Share Posted December 20, 2012 We are now 6 years later and this is not working. Well, as far as I can see. The link for feature request does not exists (anymore).Almost all my charts will be based on subreports - return values, but I don't think I can solve this problem within Jasper?Regards,gootjemar 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