wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes How to generate charts using cewolf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "How to generate charts using cewolf" Watch "How to generate charts using cewolf" New topic
Author

How to generate charts using cewolf

Vijay Reddy Pyreddy
Greenhorn

Joined: Sep 16, 2008
Posts: 3
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
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

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.


SCJP, SCWCD.
|Asking Good Questions|
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
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.


Ping & DNS - my free Android networking tools app
Vijay Reddy Pyreddy
Greenhorn

Joined: Sep 16, 2008
Posts: 3
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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
Yes, it's me who put out the bug-fixed version.

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 ]
Vijay Reddy Pyreddy
Greenhorn

Joined: Sep 16, 2008
Posts: 3
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.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
Yes, that's possible. If you look at the "Cewolf Set" example you'll see that it has multiple chart types generated from the same DatasetProducer object.
 
jQuery in Action, 2nd edition
 
subject: How to generate charts using cewolf
 
Similar Threads
cewolf PieEnhancer
cewolf charts
cewolf
Cewolf charts colors and Postprocessors
Cewolf and database?