• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Generating dynamic bar-charts

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to dynamically generate some bar-charts in a JSP page. I was wondering if anyone knows of any good ways of doing it?
I thought of making an applet, but I may have to display up to 20 of them at a time, with different parameters, so I'm worried applets would just take for ever to load...
I wonder if there are any other (free) solutions floating around?
Any suggestions gratefully recieved!!
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hope this may be of some use for you
http://www.object-refinery.com/jfreechart/index.html
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lucy,
This is what I was looking for. As you said you can do it with applets. I hate them!!. But finally this was the only option I had. The preferred way is to generate GIF files from the server, and there are free libraries to do that. BUT some restrictions come on the way. Fist, you are posting you question in JSP forum. I presume you want to do it with JSP. The library I have seen got classes that use outputstreams to which is not abtainable in JSP(I posted a question just days ago). So you have to opte for Servlets. Second. You have to check where you servlet container installed(Platform). If it's Windows that's fine. You will not have problem with Graphics. If it's Unix which is my case, it's difficult if you have not access to system properties.
Check out these links:
Java Analysis Studio
PJAToolkit
If you manage to do it on Unix platform please to me know.
Jamal
[ August 12, 2002: Message edited by: Jamal Romero ]
[ August 12, 2002: Message edited by: Jamal Romero ]
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's funny - I demonstrate two tricks for doing this using HTML alone in my new book, "JSTL in Action" (http://www.amazon.com/exec/obidos/ASIN/1930110529).
Effectively, you can create a reasonably good-looking bar chart using dynamic-width table cells and JSTL's <c:forEach> tag. You can also set the width or height of an image to equal a scoped attribute corresponding to some of your data.
Of course, for fine-grained control over graphics, you should probably generate a JPG or GIF dynamically and vend it with a servlet, not a JSP page. But for simple graphs -- such as showing survey results -- the lightweight trick works quite well.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Someone else has already mentioned JFreeChart - thanks!
Since this is a JSP forum, you should also be aware of Cewolf, a JSP tag library based on JFreeChart:
http://cewolf.sourceforge.net/
There is also a link from the JFreeChart page.
Regards,
Dave Gilbert
JFreeChart Project Leader
 
Lucy Smaile
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to give you an update, someone else suggested building dynamic html tables and just altering the width attribute dynamically - it's blissfully simple and works fine. Maybe that's similar to Shawn's technique? I only had some very simple charts to produce. Thanks for all the suggestions anyway!
Lucy
[ August 15, 2002: Message edited by: Lucy Smaile ]
 
Shawn Bayern
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lucy Smaile:
Just to give you an update, someone else suggested building dynamic html tables and just altering the width attribute dynamically - it's blissfully simple and works fine. Maybe that's similar to Shawn's technique? I only had some very simple charts to produce. Thanks for all the suggestions anyway!
Lucy
[ August 15, 2002: Message edited by: Lucy Smaile ]


Yeah, that's effectively one of the techniques I demonstrate in JSTL in Action. I've always thought it was a cute trick.
Best,
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jamal Romero:
Hi Lucy,
This is what I was looking for. As you said you can do it with applets. I hate them!!. But finally this was the only option I had. The preferred way is to generate GIF files from the server, and there are free libraries to do that. BUT some restrictions come on the way. Fist, you are posting you question in JSP forum. I presume you want to do it with JSP. The library I have seen got classes that use outputstreams to which is not abtainable in JSP(I posted a question just days ago). So you have to opte for Servlets. Second. You have to check where you servlet container installed(Platform). If it's Windows that's fine. You will not have problem with Graphics. If it's Unix which is my case, it's difficult if you have not access to system properties.
Check out these links:
Java Analysis Studio
PJAToolkit
If you manage to do it on Unix platform please to me know.
Jamal
[ August 12, 2002: Message edited by: Jamal Romero ]
[ August 12, 2002: Message edited by: Jamal Romero ]



J2SDK1.4 has addressed the issue of having to run a graphics environment emulator (such as the X virtual frame buffer). You can now run the virtual machine in "headless" mode, which allows you to generate graphics on a UNIX machine which does not have X running.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to look at RChart:
http://www.java4less.com and click on "RChart".
It has the following advantages:
- very reasonable price (starting at $24)
- Documentation , support and online-tutorial are included in the price.
- Works as applet, servlet or bean.
- It works with java 1.1 also
- Supports more than 18 types of charts andhas interactive features (zoom,tips,scroll,html
links)
- Includes RChart Visual Builder (almost no programming)
- Can read data from database.
- source code is available can be freely modified for commercial applications also.
reply
    Bookmark Topic Watch Topic
  • New Topic