Regards,
Dave Gilbert
JFreeChart Project Leader
Code: Select all
JFREECHART FREQUENTLY ASKED QUESTIONS (AND ANSWERS)
---------------------------------------------------
(C)opyright, 2004, by Object Refinery Limited.
Last updated 20 April 2004.
This FAQ is designed to answer some of the questions that get asked over
and over again in the support forum. Please read it. Note that there is
also some important information in the README.txt file that is included
in the JFreeChart distribution. Please read that too.
-------------------------------------------------------------------------------
1. I'm getting classpath errors (NoClassDefFoundException etc.), can you help
me?
2. I can't find the source code for classes in the org.jfree.ui package (for
example, org.jfree.ui.RefineryUtilities). Where are they?
3. Can I use JFreeChart in an applet?
4. Can I use JFreeChart in a commercial (closed source) application? Do I
need to pay a fee?
5. Does JFreeChart support real-time charting?
6. I want to set my own colors for each series in my chart. How do I do that?
7. The y-axis on my chart shows decimal fractions, but I only want it to
display integral values. Does JFreeChart support this?
8. I am using Unicode characters in my chart title, but they aren't being
displayed properly. What is going wrong?
9. I see that JFreeChart can export to JPEG and PNG format - which is better?
10. My web application runs fine on my Windows development machine, but when
I deploy it to the Unix/Linux production server, it doesn't work. What
is the problem?
11. I've found a bug, where do I report it?
12. I've made some changes to the JFreeChart source code, and I'd like to
contribute these back to the project. Where do I submit them?
-------------------------------------------------------------------------------
1. I'm getting classpath errors (NoClassDefFoundException etc.), can you help
me?
The usual causes of classpath problems are (in order of frequency):
(a) New users that don't really understand what the classpath is about, and
how it works. If this is you, find a good introductory book on Java and
read up about the classpath until you understand it. You won't get
anywhere with Java until you understand how Java finds and loads classes.
(b) You have more than one copy of the JFreeChart and/or JCommon jar files
on the current classpath.
(c) You have an out-of-date version of JCommon (this is not really a classpath
issue, but users often report it as such).
(d) Very occasionally, a jar file can be corrupted for whatever reason. If
nothing else works for you, try downloading a fresh copy of the required
jar file(s) (this goes for any jar file, not just the JFreeChart/JCommon
jar files).
-------------------------------------------------------------------------------
2. I can't find the source code for classes in the org.jfree.ui package (for
example, org.jfree.ui.RefineryUtilities). Where are they?
The org.jfree.ui package is part of the JCommon class library. The runtime
jar file is included in the JFreeChart distribution, source code and
documentation is available separately from:
http://www.jfree.org/jcommon/index.html
Like JFreeChart, JCommon is also licensed under the terms of the GNU LGPL.
-------------------------------------------------------------------------------
3. Can I use JFreeChart in an applet?
Yes, there is a demo at http://www.object-refinery.com/jfreechart/applet.html.
There are some provisos though:
- you need a web browser that supports Java 2 (JDK 1.2.2 or higher). To
find out what version your browser supports, try the following web
page:
http://javatester.org/version.html.
Virtually all browsers support Java 2 EXCEPT for Microsoft Internet
Explorer (MSIE). You can install Sun's Java Plugin to get MSIE to
work properly or, better still, download and install Mozilla.
- JFreeChart doesn't incorporate any special applet features. For
example, you can't pass data to the chart applet via HTML as you can
in some charting packages.
- we haven't made any special effort to minimise the size of the
JFreeChart jar files. It is something that could be done, but really
the demand for it is low, so it hasn't been done yet.
-------------------------------------------------------------------------------
4. Can I use JFreeChart in a commercial (closed source) application? Do I
need to pay a fee?
Yes, the license (GNU LGPL) allows this. There are no license fee to pay,
but you must adhere to the terms of the license. There is more information
contained at the end of the jfreechart-<version>-install.pdf document.
-------------------------------------------------------------------------------
5. Does JFreeChart support real-time charting?
Not really. JFreeChart includes an event-notification mechanism that ensures
that charts are updated whenever the dataset is updated. However, the chart
is completely repainted for each update, which limits the "frames per second"
rate that you can achieve with JFreeChart. Typically, updating once per
second is fine, but updating multiple times per second involves a lot of CPU
load. If you want to pursue this, do some testing for your own circumstances.
-------------------------------------------------------------------------------
6. I want to set my own colors for each series in my chart. How do I do that?
You can use the setSeriesPaint() method in the renderer. For example, the
following code could be used for a bar chart:
CategoryItemRenderer renderer = plot.getRenderer();
renderer.setSeriesPaint(0, Color.green);
renderer.setSeriesPaint(1, Color.red);
// and so on...
-------------------------------------------------------------------------------
7. The y-axis on my chart shows decimal fractions, but I only want it to
display integral values. Does JFreeChart support this?
Yes, you can replace the collection of standard tick units for the axis
as follows:
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
-------------------------------------------------------------------------------
8. I am using Unicode characters in my chart title, but they aren't being
displayed properly. What is going wrong?
Most often, the problem is that the font being used to display the
title doesn't have support for the Unicode characters being used. Try
this link for more information about fonts that support Unicode:
http://www.alanwood.net/unicode/fonts.html
-------------------------------------------------------------------------------
9. I see that JFreeChart can export to JPEG and PNG format - which is better?
PNG by a long way. JPEG is designed for compressing photographs where a small
loss in quality is usually acceptable (and not very noticeable). For chart
images, where there are usually sharp distinctions between areas of color, the
artifacts introduced by the JPEG format are very noticeable. Don't use JPEG
unless you absolutely have to. The PNG format is "lossless", so chart images
are always reproduced perfectly.
-------------------------------------------------------------------------------
10. My web application runs fine on my Windows development machine, but when
I deploy it to the Unix/Linux production server, it doesn't work. What
is the problem?
Most likely your server does not have X11 running. This is a Java
(AWT/Java2D) issue, not something that is specific to JFreeChart. There is
some more information at Sun's website:
http://java.sun.com/products/java-media/2D/forDevelopers/java2dfaq.html#xvfb
In addition, the following thread in the JFreeChart forum contains some
useful information:
http://www.jfree.org/phpBB2/viewtopic.php?t=1012
-------------------------------------------------------------------------------
11. I've found a bug, where do I report it?
You can use the bug tracker on the JFreeChart project page at SourceForge:
http://sourceforge.net/tracker/?group_id=15494&atid=115494
-------------------------------------------------------------------------------
12. I've made some changes to the JFreeChart source code, and I'd like to
contribute these back to the project. Where do I submit them?
You can use the patch manager on the JFreeChart project page at SourceForge:
http://sourceforge.net/tracker/?group_id=15494&atid=315494