• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to generate charts using cewolf

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Vijay Reddy Pyreddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic