Frequently Asked Questions (FAQ)
This page contains a list of frequently asked questions, along with answers of course:
- I'm getting classpath errors (NoClassDefFoundException etc.), can you help me?
- I can't find the source code for classes in the org.jfree.ui package (for example, org.jfree.ui.RefineryUtilities). Where are they?
- Can I use JFreeChart in an applet?
- Can I use JFreeChart in a commercial (closed source) application? Do I need to pay a fee?
- Does JFreeChart support real-time charting?
- I want to set my own colors for each series in my chart. How do I do that?
- The y-axis on my chart shows decimal fractions, but I only want it to display integral values. Does JFreeChart support this?
- I am using Unicode characters in my chart title, but they aren't being displayed properly. What is going wrong?
- I see that JFreeChart can export to JPEG and PNG format - which is better?
- 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?
- I've found a bug, where do I report it?
- 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 a patch?
- Are there other "open source" chart libraries?
1. I'm getting classpath errors (NoClassDefFoundException etc.), can you help me?
The usual causes of classpath problems are (in order of frequency):- 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.
- You have more than one copy of the JFreeChart and/or JCommon jar files on the current classpath.
- You have an out-of-date version of JCommon (this is not really a classpath issue, but users often report it as such).
- 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:
Like JFreeChart, JCommon is also licensed under the terms of the GNU Lesser General Public Licence.
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.3.1 or higher). To find out what version your browser supports, try the following web page: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 FireFox.
- 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 licence (GNU LGPL) allows this. There is no licence fee to pay, but you must adhere to the terms of the licence. 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 results in high CPU load. If you want to pursue this, do some performance testing with your specific configuration and use cases.
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:
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:
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:
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:
In addition, the following thread in the JFreeChart forum contains some useful information:
11. I've found a bug, where do I report it?
You can use the bug tracker on the JFreeChart project page at SourceForge:
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 a patch?
You can use the patch manager on the JFreeChart project page at SourceForge:
13. Are there other "open source" chart libraries?
Yes. If JFreeChart doesn't meet your requirements, try one of the following free/open source alternatives:
- the JCCKit project (LGPL);
- the QN Plot project (BSD);
- the OpenChart2 project (LGPL);
- the PtPlot project (UC Berkeley copyright);
- the JRobin project (LGPL);
- the Java Chart Construction Kit (LGPL, works with JDK 1.1.8);
- the JOpenChart project (LGPL);
- the jCharts project (BSD-style);
- the JChart2D project (LGPL);
- the Chart2D project (LGPL);
- the ThunderGraph project (LGPL);
- the E-Gantt project (Q Public License);
- the MagPlot project (GPL) previously at https://magplot.dev.java.net/;
- the XChart project (Apache 2.0);
- the Project Waterloo (LGPLv3);