Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple Charts in jsp  RSS feed

 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to implement simple charts (bar , line, pie) in jsp.

My requirements are that the chart will be accessed by multiple users therefore should be dynamic, i have come across components that provide the charts as image file and does not seem to be a viable option.

I am alos looking for an API thats eay to implement and free,
any leeds ...?

regards
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
will be accessed by multiple users therefore should be dynamic, i have come across components that provide the charts as image file and does not seem to be a viable option.

I'm not sure how "access by multiple users" implies "image needs to be dynamic", nor how "chart is an image file" implies "is not a viable option". Could you elaborate a bit on your requirements?

JFreeChart is a popular library that generates image charts, yet does so on the fly, i.e. dynamic. There's also a taglib named "cewolf" for it which makes it easy to incoporate those images in web pages.
 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply.
Initially i was skeptical about using cewolf's API but it surpassed all my expectations , i faced some problems getting started but soon solved them.

My main problem now is that the the bar/line graphs are coming fine but when there is alot of points on the X-axis the values can not be seen clearly.


If you see the dates on the x-axis are getting overlapped, isint there a way to have the dates shown vertically as on the x-axis.
[ April 25, 2006: Message edited by: madhup narain ]
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I used JFree charts to implement the charts, and i prefer to you touse them which are very easy to implement.

If u want i can also provide some code to u.

org.jfree.data.general.DefaultPieDataset myDataSet=new org.jfree.data.general.DefaultPieDataset();
myDataSet.setValue("apple",100);
myDataSet.setValue("pear",200);
myDataSet.setValue("grape",300);
myDataSet.setValue("bannana",400);
myDataSet.setValue("orange",500);
JFreeChart chart=ChartFactory.createPieChart3D("fruit production chart",myDataSet,true,true,true);
chart.setBackgroundPaint(java.awt.Color.white);
chart.setBorderVisible(false);
ChartUtilities.writeChartAsJPEG(response.getOutputStream(),100,chart,400,300,thisImageMapInfo);


this is the code to draw a pie chart...if u want i can give code for bar chart also...

bye
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Sorry to forget adding these two lines before the above code

first these lines---

response.setContentType("image/jpeg");
ChartRenderingInfo thisImageMapInfo=new ChartRenderingInfo();

then the above given code...
ok bye..
 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The CEWOLF's tag library seems to be pretty good. I was able to get my charts up and running after quite a lot of research. The library is pretty extensive and you may have to go through the JFreeChart's API to get some of the stuff.
working.

For those of you who are looking to use charts i would recommend CEWOLF. Follow instructions and you'd get going, sometimes it may take you a little effort but dont give up, the rewards are great when you see the chart come to life.

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!