I want to use JFreeChart for my Website. As I understand it, JFReechart creates graphics for client side use only.
However, if this is correct, then would there be a problem using JFreeChart in a Java Web app where I just used it to create JPEG files that an image's "img source" used in a web page would display?
Do I have other options with JFreeChart and Web apps?
Thanks in advance.
M
JFreeChart for a Website
Your first line is a bit ambiguous - Jfree runs on the server. It makes images that are sent to the client.
Otherwise, I think it's OK: JFree is a class library (a set of objects and methods) that allows you to generate an image file. So your webpage would contain an <img> tag whose "src" attribute would point to a URL on your site. That URL would then execute a java program in your webapps server that would then call Jfree methods to create the chart image and return it.
Otherwise, I think it's OK: JFree is a class library (a set of objects and methods) that allows you to generate an image file. So your webpage would contain an <img> tag whose "src" attribute would point to a URL on your site. That URL would then execute a java program in your webapps server that would then call Jfree methods to create the chart image and return it.
The package org.jfree.chart.servlet appears to have some stuff to assist with using JFreeChart in a Servlet environment, but it looks pretty basic.
A better bet if your using JSP might be to use the Cewolf tag library to help you manage the process of creating the img tags and rendering the chart when the browser requests it and I think theres some image caching stuff in there too.
If you want to manage it all yourself thats not too hard either. There are some useful methods in org.jfree.chart.encoders.EncoderUtil that can create png and jpeg images from the BufferedImage returned by JFreeChart.createBufferedImage() that you can then stream out to the client.
A final option in theory would be Applets, but I wouldn't recommend that (except perhaps in a LAN environment) due to the size of the jars involved and the need for an appropriate version of the Java plugin clientside.
I think your best option from the above is Cewolf.
A better bet if your using JSP might be to use the Cewolf tag library to help you manage the process of creating the img tags and rendering the chart when the browser requests it and I think theres some image caching stuff in there too.
If you want to manage it all yourself thats not too hard either. There are some useful methods in org.jfree.chart.encoders.EncoderUtil that can create png and jpeg images from the BufferedImage returned by JFreeChart.createBufferedImage() that you can then stream out to the client.
A final option in theory would be Applets, but I wouldn't recommend that (except perhaps in a LAN environment) due to the size of the jars involved and the need for an appropriate version of the Java plugin clientside.
I think your best option from the above is Cewolf.
Thanks Oscar for your reply.
In my first sentence, I just meant that I didn't think that JFree could create images directly for a Webpage like it can for a Java application.
That's why I was trying to make sure there wasn't any problem with creating image FILES using JFree that I could include with an img src.
M
In my first sentence, I just meant that I didn't think that JFree could create images directly for a Webpage like it can for a Java application.
That's why I was trying to make sure there wasn't any problem with creating image FILES using JFree that I could include with an img src.
M
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
As far as I can tell, the majority of developers use JFreeChart for web applications. I, myself, use JFreeChart for client-side development, and there seems to be a growing number of people doing this...but we're still the minority I think.mork wrote:In my first sentence, I just meant that I didn't think that JFree could create images directly for a Webpage like it can for a Java application.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


What exactly do you mean by "directly for a Webpage"?mork wrote:In my first sentence, I just meant that I didn't think that JFree could create images directly for a Webpage like it can for a Java application.
If you think about embedding binary data in an html stream, the answer is you can do that but you won't like the result (as the browser wouldn't render it as an image, naturally as it's not an image according to the http headers).
If you want to stream an image directly from your server to the client through an http request, that's quite possible.
No need to create any image files on disk, just create them in memory and send them over the wire.