Jump to content
We've recently updated our Privacy Statement, available here ×

Use Subreport return value for charts?


JulEgner

Recommended Posts

  • Replies 13
  • Created
  • Last Reply

Top Posters In This Topic

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

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

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

  • 2 months later...

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: Bean

Type: Custom JRDatasource

Factory Class: Dreamer.iReport.iReportBeanCollector

Static 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

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,

 

midrag

Post edited by: midrag, at: 2006/11/15 15:34

Link to comment
Share on other sites

  • 6 years later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...