While JFreeChart is an ideal library for drawing 2D charts, sometimes it's necessary to move to 3D. A good solution is Jzy3d, an open source library focusing on drawing 3D data using surfaces, scatter plots, bar charts, and other 3D primitives. It's built upon JOGL 2, which means that the charts utilize OpenGL internally, but its low-level elements are mostly kept hidden. There are Jzy3d classes that let charts be integrated with Swing, AWT, SWT or JavaFX, but all of my examples utilize Swing.
For information on Jzy3d, see:
JOGL is a separate download from Jzy3d, and it can be a bit tricky to set up. I've used the current 'fat' 2.4 version, jogamp-fat.jar, which I've included with the other Jzy3d libraries in the "Download" section
JOGLQuad.java is a simple JOGL program written by Julien Gouesse, which displays a rotating, sky blue quad against a black background. I've included it so that you can test the JOGL installation separately from Jzy3d. Click here for a screenshot. Details on how to compile and run this example, and the others, are in the comments of the source code.
There are four charting examples:
The surface and scatter plot examples of the previous section are modified in order to change their plotted data over time:
PickScatter.java is based on the scatter plot from section 2, but adds picking capability. When the mouse is moved over a point, that point will be highlighted in red and its coordinate displayed in an overlay window. Click here for a screenshot.
I've had two problems with this example.
1. In a multiple monitor setup (with different resolutions), the wrong point is highlighted when the application window is running on one of the screens. However, the correct point is selected when it is executing on the other screen.
2. When I click the close box, the program takes longer and longer to actually close depending on how long is has been running. If I wait long enough, then when I click 'close' the following exception is raised:
Exception in thread "AWT-EventQueue-0" com.jogamp.opengl.GLException:Caught GLException: Context still current after 512 releases: WindowsWGLContext [Version 4.6 ....
It seems to originate from JOGL in forceNativeRelease().
I've added a WindowListener to 'fix' this problem. The delay still occurs, but the exception is quietly caught, allowing the program to exit normally.