Hi, This is my first Time on any forum. I have a problem in generating graphs with cewolf. We have an application where we should generate the pie charts of employees versus the time taken for each category. I am using cewolf to generate charts.I am able to generate chart when there is only one category.Problem arises when there are more categories. I have to generate chart for each category retrieved.I did a lot of googling but couldn't find the solution. How to pass the parameters to the action class .I cannot paste the code because its an internal project of our company.Any one please give sample code . And how to create multiple charts using a single java class rather than separate class for each. Please give me the answer. Thanks in advance
Hi Vijay Reddy Pyreddy welcome to Javaranch This looks like a Struts question and should be in the corresponding forum.One of the moderators will move it to its appropriate place. Also take some time to read the Ask good questions link below.
The charts created by cewolf (and JFreeChart, which is the chart engine behind it) can visualize only a single dataset at a time. If you want multiple pie charts, then you'll need multiple chart images on the page.
You can create multiple charts using the same DatasetProducer object, you just need to pass in a parameter that differentiates the various charts. In your case this might be some kind of employee ID, so that the class knows which data to visualize.
Does this help?
I'll move the question to the Other Open Source projects forum, where cewolf is discussed.
Sorry to bother again. Can you please give some sample code Mr.UlfDittmer.I came across a cewolf version released by you.I am sure that I am with right person and i think i can get answer.How to pass the parameters to dataproducer class. Do I need to create another class where i can get the data from database and then pass it to dataproducer class.If so how does the jsp differentiate between the charts generated. Does the charts get over written.Please help me as i am in urgent need. . i hardly have 2 days to submit my code.Thanks again
The cewolfexample web app that comes with it has a number of examples that show how to pass parameters around.
In your example of one chart per employee, you'll probably have a loop in the JSP that iterates over all employees. In the loop, you'd have a <cewolf:chart> tag and a <cewolf:img> tag. Inside the chart->data->producer tag you can use EL to create different IDs that retrieve the chart objects with corresponding names. Earlier, in your servlet, you'd have put these objects into the request scope as attributes.
If the DatasetProducer class needs parameters, then you can pass them in the constructor, or through regular setter methods. This all happens in the servlet code, so you can do everything that normal Java code can do, including accessing a database to retrieve the data required for the charts. [ September 16, 2008: Message edited by: Ulf Dittmer ]
Thanks a lot MR.UlfDittmer. My problem is solved.I am able to generate the graphs as I wanted. I downloaded the version released by you and followed the examples.It was very useful.I have another doubt. I want to generate different types of charts.But as of now I am writing a separate class to generate each type. Is it possible to use the same class for all the charts.If yes, how? Please clarify it. Thanks once again.