Hi,
JFreeChart is great, I've been able to produce a dynamic chart applet with it.
For some reason, however, other people can't seem to view my applet. I can see it fine with my own computer, but nobody else seems to be able to load it.
Any suggestions? If I use your library, do I need to upload the library too and perhaps link it to my html?
Mark
Applets using JFreeChart
RE: Applets using JFreeChart
Hi Mark,
There's a couple of possibilities:
(1) The others don't have Java 2 capable browsers.
(2) You haven't included all the required JFreeChart classes.
I don't use applets myself, but at some point I'd like to put together some documentation on how to deploy a JFreeChart applet, so if anyone has done this and has some tips, please post here...
Regards,
DG.
There's a couple of possibilities:
(1) The others don't have Java 2 capable browsers.
(2) You haven't included all the required JFreeChart classes.
I don't use applets myself, but at some point I'd like to put together some documentation on how to deploy a JFreeChart applet, so if anyone has done this and has some tips, please post here...
Regards,
DG.
RE: Applets using JFreeChart
One of the projects our team is developing has a consumer facing web interface with data charting capabilities. We've been using JFreeChart with a great deal of success on this project - it's entering beta at the end of the month.
One of the biggest debates in designing the system was where to render the charts - on the server or on the client (with either applets or activex controls). Both choices have their pro's and con's, mostly trading between server performance and client compatibility. In the end, we chose to have the app server render the datasets into charts on the fly, writing a jpeg stream back to the client's browser. This has worked great so far, with no performance issues under our load tests.
With the ChartUtilities.writeChartAsJPEG() method, it's even easier now - we had to do all that ourselves since we started on an earlier release
Anyway, I know this doesn't help directly resolve your applet issues, but without knowing the constraints of your application, I'd encourage you to look at server side rendering if you keep having compatibility issues...
--L
One of the biggest debates in designing the system was where to render the charts - on the server or on the client (with either applets or activex controls). Both choices have their pro's and con's, mostly trading between server performance and client compatibility. In the end, we chose to have the app server render the datasets into charts on the fly, writing a jpeg stream back to the client's browser. This has worked great so far, with no performance issues under our load tests.
With the ChartUtilities.writeChartAsJPEG() method, it's even easier now - we had to do all that ourselves since we started on an earlier release

Anyway, I know this doesn't help directly resolve your applet issues, but without knowing the constraints of your application, I'd encourage you to look at server side rendering if you keep having compatibility issues...
--L
RE: Applets using JFreeChart
I tried a sample applet - it works with appletviewer, but when I try
to load it from a browser, it gives an error
"Simple can't be instantiated".
here is the html file:
<title> applet demo </title>
<APPLET CODE = "Simple.class" ARCHIVE= "jfreechart-0.7.1.jar,
jcommon-0.5.3.jar" WIDTH = "550" HEIGHT = "500" vspace=500 hspace=500>
</APPLET>
Simple.class and the jar files are in the same directory.
Thanks,
siva
to load it from a browser, it gives an error
"Simple can't be instantiated".
here is the html file:
<title> applet demo </title>
<APPLET CODE = "Simple.class" ARCHIVE= "jfreechart-0.7.1.jar,
jcommon-0.5.3.jar" WIDTH = "550" HEIGHT = "500" vspace=500 hspace=500>
</APPLET>
Simple.class and the jar files are in the same directory.
Thanks,
siva
RE: Applets using JFreeChart
Here is a sample applet if someone wants to try. I copied some code from ServletDemo class and converted it to an applet. It works with appletviewer but does not work on a brower. I think there is some set up issue:
import java.applet.Applet;
import java.awt.*;
import java.awt.Graphics;
import java.awt.image.*;
import java.awt.geom.*;
import com.jrefinery.chart.*;
import com.jrefinery.chart.data.*;
import com.jrefinery.chart.ui.*;
import com.jrefinery.data.*;
import com.jrefinery.ui.*;
public class Simple extends Applet {
StringBuffer buffer;
JFreeChart chart;
CategoryDataset categoryData = createCategoryDataset();
public CategoryDataset createCategoryDataset() {
Number[][] data = new Integer[][] {
{ new Integer(10), new Integer(4), new Integer(15), new Integer(14) },
{ new Integer(5), new Integer(7), new Integer(14), new Integer(3) },
{ new Integer(6), new Integer(17), new Integer(12), new Integer(7) },
{ new Integer(7), new Integer(15), new Integer(11), new Integer(0) },
{ new Integer(8), new Integer(6), new Integer(10), new Integer(9) },
{ new Integer(9), new Integer(8), new Integer(8), new Integer(6) },
{ new Integer(10), new Integer(9), new Integer(7), new Integer(7) },
{ new Integer(11), new Integer(13), new Integer(9), new Integer(9) },
{ new Integer(3), new Integer(7), new Integer(11), new Integer(10) }
};
return new DefaultCategoryDataset(data);
}
public void init() {
repaint();
}
public void paint(Graphics g) {
chart = ChartFactory.createVerticalBarChart(
"Vertical Bar Chart",
"Categories",
"Values",
categoryData, true);
Plot bPlot = chart.getPlot();
HorizontalCategoryAxis cAxis = (HorizontalCategoryAxis)bPlot.getAxis(Plot.HORIZONTAL_AXIS);
cAxis.setVerticalCategoryLabels(true);
//Draw a Rectangle around the applet's display area.
g.drawRect(0, 0, size().width - 1, size().height - 1);
BufferedImage img = chart.createBufferedImage(
size().width - 1, size().height - 1);
g.drawImage((Image) img, 0,0,new Color(1),null);
}
}
/* here is a the html file
<title> applet demo </title>
<APPLET CODE = "Simple.class" ARCHIVE= "jfreechart-0.7.1.jar,
jcommon-0.5.3.jar" WIDTH = "550" HEIGHT = "500">
</APPLET>
*/
If someone knows the problem, please let me know.
Siva
import java.applet.Applet;
import java.awt.*;
import java.awt.Graphics;
import java.awt.image.*;
import java.awt.geom.*;
import com.jrefinery.chart.*;
import com.jrefinery.chart.data.*;
import com.jrefinery.chart.ui.*;
import com.jrefinery.data.*;
import com.jrefinery.ui.*;
public class Simple extends Applet {
StringBuffer buffer;
JFreeChart chart;
CategoryDataset categoryData = createCategoryDataset();
public CategoryDataset createCategoryDataset() {
Number[][] data = new Integer[][] {
{ new Integer(10), new Integer(4), new Integer(15), new Integer(14) },
{ new Integer(5), new Integer(7), new Integer(14), new Integer(3) },
{ new Integer(6), new Integer(17), new Integer(12), new Integer(7) },
{ new Integer(7), new Integer(15), new Integer(11), new Integer(0) },
{ new Integer(8), new Integer(6), new Integer(10), new Integer(9) },
{ new Integer(9), new Integer(8), new Integer(8), new Integer(6) },
{ new Integer(10), new Integer(9), new Integer(7), new Integer(7) },
{ new Integer(11), new Integer(13), new Integer(9), new Integer(9) },
{ new Integer(3), new Integer(7), new Integer(11), new Integer(10) }
};
return new DefaultCategoryDataset(data);
}
public void init() {
repaint();
}
public void paint(Graphics g) {
chart = ChartFactory.createVerticalBarChart(
"Vertical Bar Chart",
"Categories",
"Values",
categoryData, true);
Plot bPlot = chart.getPlot();
HorizontalCategoryAxis cAxis = (HorizontalCategoryAxis)bPlot.getAxis(Plot.HORIZONTAL_AXIS);
cAxis.setVerticalCategoryLabels(true);
//Draw a Rectangle around the applet's display area.
g.drawRect(0, 0, size().width - 1, size().height - 1);
BufferedImage img = chart.createBufferedImage(
size().width - 1, size().height - 1);
g.drawImage((Image) img, 0,0,new Color(1),null);
}
}
/* here is a the html file
<title> applet demo </title>
<APPLET CODE = "Simple.class" ARCHIVE= "jfreechart-0.7.1.jar,
jcommon-0.5.3.jar" WIDTH = "550" HEIGHT = "500">
</APPLET>
*/
If someone knows the problem, please let me know.
Siva
Re: Applets using JFreeChart
I found out that my browser requires java plug-in for this to work since
jfreechart uses JDK 1.2 features such as buffered image. Microsoft
IE 5.0 has built in support for only JDK 1.1.4.
I have not tried to use the plug-in but once you download and install Java plug-in, this applet should work.
Siva
jfreechart uses JDK 1.2 features such as buffered image. Microsoft
IE 5.0 has built in support for only JDK 1.1.4.
I have not tried to use the plug-in but once you download and install Java plug-in, this applet should work.
Siva
Re: Applets using JFreeChart
Install thr SDK 1.3.1_01 and then
look at the sample and source at
chart.thrx.de
look at the sample and source at
chart.thrx.de