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

building a Chart with an Array


law

Recommended Posts

Hi all,
I have an array that gets populated in a Scriptlet. I assign the scriptlet's output to a variable in my iReport.
I had tested the variable/Scriptlet output with both types Long[] and List. I'm getting very similar results:
the array gets populated, I can see it grow in "Detail" band, then I can view the content of it in the "Summary" band.

The problem comes when I attempt to set it as a "Category Expresion" in one of iReport charts.
When the array in a Long[], the error is:
Error filling print... [Ljava.lang.Long; cannot be cast to java.lang.Comparable

When the array in a String[], the error is:

Error filling print... [Ljava.lang.String; cannot be cast to java.lang.Comparable

When the array is a List, the error is:  
Error filling print... java.util.ArrayList cannot be cast to java.lang.Comparable

Class Long & String do implement Comparable. Am I missing a cast? not sure how to pipe the content of an array into an iReport chart. Any clues anyone?



Post Edited by liw at 08/20/2012 21:53
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Here is something I'm trying right now. I think it is possible that the first time the chart attempt to access my array it is undefined and hence I get the error. I'm thinking the syntax below would give the right value as the chart gets created. In "Category Expession" I'm trying now:

$V{likesDiff}.length >0 ? $V{likesDiff}[likesDiff.length]:0

So far the error is

Error filling print... Error evaluating expression :      Source text : $V{likesDiff}.length >0 ? $V{likesDiff}[likesDiff.length]:0

I'm still hoping to make a chart out of an array.

 

 

 

Link to comment
Share on other sites

  • 2 years later...

Hi liw,

Would you be so kind to post the code for the first part of your question? That is, the scriplet to populate the array and how to display the array contents in the detail band and on the summary band as well?

I am new to iRepor and it will be great to get your help.

 

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