jijynasu Posted June 29, 2007 Share Posted June 29, 2007 I have data in an arraylist and that i want to print in the form of graph. I don't want to set any connection in the iReport and am not writing any sql-querry in iReport. How can i create a temlate(jrxml file) so that i can can pass my value to generate a graph. My application is built on eclipse. plz help... Link to comment Share on other sites More sharing options...
aditya_gupta Posted June 29, 2007 Share Posted June 29, 2007 HI,You can use set the datasource in ireport to JavaBean Collection Datasource, which allow us to print the data using purposely written java classes. The JavaBean set datasource uses an external class (named Factory) to produce some objects (the JavaBean) that constitute the data to pass to the report. In ireport, Goto Data -> Connections / Datasources -> new. The parameters for the datasource configuration will be:Name: TestFactoryDataSource(user defined)Type of Datasource : JavaBean set Datasourceclass: Test (name of fully classified classpath which is having collection)Method to call: name of method in classReturn type: Collection of JavaBean and then Test the connection. After succesful connection, save it. One more thing the class or package should be in classpath of ireport. Go to report query section, select javabean data source tab and type the class name and click read attributes. Your are done. I think this will work for you. Aditya Link to comment Share on other sites More sharing options...
jijynasu Posted June 29, 2007 Author Share Posted June 29, 2007 Thanks for the reply Aditya,Now the problem is i am new to the iReport and Jasper. Would you plz tell me in steps What to do and where to do? Link to comment Share on other sites More sharing options...
aditya_gupta Posted June 30, 2007 Share Posted June 30, 2007 Hi, It is very simple. You put ur arraylist in a class. Here is a sample code. public class Test{public static java.util.ArrayList generateCollection(){java.util.ArrayList list = new java.util.ArrayList();list.add(20);list.add(34);list.add(56); return list;}} Put this clas file in the class path of ireport. for this goto option menu -> classpath and select Add folder and provide the path of your class file and save classpath . after all these, Goto Data -> Connections / Datasources -> new. The parameters for the datasource configuration will be: Name: TestFactoryDataSource(user defined) Type of Datasource : JavaBean set Datasource class: Test (name of fully classified classpath which is having collection) Method to call: name of method in class Return type: Collection of JavaBean and then Test the connection. After succesful connection, save it. Go to report query section, select javabean data source tab and type the class name and click read attributes. I think this will help you Aditya Link to comment Share on other sites More sharing options...
aditya_gupta Posted June 30, 2007 Share Posted June 30, 2007 Hi, It is very simple. You put ur arraylist in a class. Here is a sample code. public class Test{public static java.util.ArrayList generateCollection(){java.util.ArrayList list = new java.util.ArrayList();list.add(20);list.add(34);list.add(56); return list;}} Put this clas file in the class path of ireport. for this goto option menu -> classpath and select Add folder and provide the path of your class file and save classpath . after all these, Goto Data -> Connections / Datasources -> new. The parameters for the datasource configuration will be: Name: TestFactoryDataSource(user defined) Type of Datasource : JavaBean set Datasource class: Test (name of fully classified classpath which is having collection) Method to call: name of method in class Return type: Collection of JavaBean and then Test the connection. After succesful connection, save it. Go to report query section, select javabean data source tab and type the class name and click read attributes. I think this will help you Aditya Link to comment Share on other sites More sharing options...
jijynasu Posted July 2, 2007 Author Share Posted July 2, 2007 Hi Aditya,Although i have done all the things you have said but the problem is how those data will map to aparticular chart in the report. I mean there must be some chart name in the jrxml file for each chart and same will be refered in the java code.In my case whatever data i am getting from the database is random(values of machine counters). x-axis is the time and y-axis is the random counter value.Also i want to know that can i make jrxml file dynamically i.e through java program.please help me to solve the issue. 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