This is a nice package; I'm thinking of using it in my RCP application. However.....
1) I created a simple JFace-based application (extends ApplicationWindow) and just plopped a ChartComposite onto it. I then created a couple of Actions that plot the various example series found in the plugin. The data appears, but try as I might I cannot get the axis markers or titles to display. Hmmm. I can send my source code if you wish.... I'm using v 1.1.1 of SimpleChart
2) One of features of my application is a real-time line graph (updated every 15 ms) of up to four series, plus a histogram updated every second. The line graph would have fixed min n max values on the X n Y axises and would chart connected points from the left, fill to the right, clear the graph when the series was 'full', and then start over. Each clear-fill cycle would last about 5 - 10 seconds.
The histogram would display a summary of the real-time graph but updated every 1 second.
Can this toolkit do something like that?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1)
As for your first question, I want to start with an obvious suggestion, just to make sure it isn't the problem, and then you can send
me a code snippet and I'll take a look at it.
Are you sure you are turning on the options to show the axis titles and markers?
2) You can definately use Simple Chart for a real time graph. I'm doing that very thing in another application I'm working on. The best way I've found to do it is to remove the series you want to update and replace it with new series. You can turn autoZoom off and set the bounds yourself:
getChart().setAutoFitXAxis(false);
getChart().setAutoFitYAxis(false);
getChart().setZoomArea(0,0,100,100); // for example
It sounds inefficient, but you should find that it updates very fast, unless the chart takes up a lot of space on the screen.
I hope that helps, and feel free to post a code snippet.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's my Action class which updates the chart. The 'Util' class is just a singleton that holds the LineChart object. I'm using Elcipse 3.2.2, JDK 1.5.0_06 on a Linux (FD 7) system.
Is there a way I can send my ApplicationWindow wrapper (e.g. some ZIP file) other than UUENCODE'ing it and posting it here?
thanks.
r
<code>
public class Plot2Action extends Action {
ApplicationWindow window;
// remove the existing chartObjects
lc.removeAllChartObjects();
// add the collection to the chart
lc.addChartObject(h);
lc.setLegendVisible(true);
lc.setXAxisLabel("XXX");
lc.setXAxisTitleVisible(true);
lc.setXAxisVisible(true);
I don't see anything wrong with the snippet you posted, so I'll need to try to reproduce it on my own. You can also send me an e-mail with a zip attached to my gmail.com address, dan.phifer. Also, attach a screen shot if you can.
I thought of a couple more things:
1. Does the example included with the package show the x and y axis labels/markers? You can toggle the x and y axis labels and markers in the drop down menu on the Line Chart view. (If you have Simplechart installed in eclipse, you can go to Window->Show View->Other... and open the two views under the Simplechart category). Also, if you are writing an RCP application, you can reuse the Line Chart view and pass it data via the selection framework in Eclipse.
2. Is it possble that the bottom of the chart is being cut off? You should see a white box around the chart area, a few pixels from the edge. Try alternating the boolean values for setXAxisTitleVisible each time the aciton is run, and see if the chart shifts up and down.
I'll take a look at it tonight or tomorrow after work.
Dan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can't seem to reproduce the problem. I've attached some code that I created to test it out. Here's the steps I used to get it running:
1. Downloaded Simplechart 1.1.1 and extracted SimpleChart_1.1.1.jar to my desktop
2. Created a new Plug-in project in eclipse (so all of the jface/swt dependencies would be set up for me)
3. Went into project properties and added the SimpleChart_1.1.1.jar to my project my clicking "Add External JARs..."
4. Create a new Class (included below) that extends ApplicationWindow
The class has an inner class that implements the action you included. Apologies if this is not readed by the sourceforge server in a friendly manner:
/*
* Created on Feb 17, 2008
*/
package testswtchart2;
// remove the existing chartObjects
lc.removeAllChartObjects();
// add the collection to the chart
lc.addChartObject(h);
lc.setLegendVisible(true);
lc.setXAxisLabel("XXX");
lc.setXAxisTitleVisible(true);
lc.setXAxisVisible(true);
Sorry for not responding earlier. Boss had me work some other project for a bit. Darn bosses... Oh, wait, I'm the boss.....
My Eclipse project is a bit different, I just extracted the source from CVS from SourceForge. I get the same problem (no axes) when I run your example above. I'll try a couple of different things, as well. Also, I'm running Eclipse 3.2.2 on a Linux system (JDK 1.5.0_06?).
I see the legend in the plot and I can successfully enable/disable the display of that, but no axes...
Lemme try a couple of other things this afternoon....
r
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
K. I tried to get a dynamic chart working. Here are the specifics:
I have (essentially) a time-series chart. The data is in refreshed 64Hz cycles (from a data collection device). Each cycle contains four data points. Each data message contains up to eight series of data.
My display class does:
<precondition>
float[] data = new float [maxXValue];
int xValue =0;
chart.addSeries ("name", data, color, false);
</precondition>
This works for about 11 cycles and then I get the following traceback almost every cycle:
Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
at java.util.AbstractList$Itr.next(AbstractList.java:420)
at chart.LineChart.drawChartObjects(LineChart.java:650)
at chart.LineChart.updateChart(LineChart.java:393)
at chart.LineChart.paint(LineChart.java:174)
at widgets.PanelSurface.notifyPaintListeners(PanelSurface.java:119)
at widgets.PanelSurface.paint(PanelSurface.java:94)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Also, the definition of a data series is a bit light for my application. My X axis is a time series and I would like to display time intervals (e.g., "00:05", "00:10") as the labels.
Plus, adding a small set of data to a series is a bit odd as it appears the LineChart draws all elements in the yValues array and if I want to add 1 - 4 points to a series that could display 10K elements would get ugly.....
I'll keep trying.
r
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmmm. The concurrent modification exception is because the repaint is still happening when trace is removed from the chart. This is a bug that I've fixed in the new version.
There are a number of options, but I'm not sure you'll like any of them:
1. You could extend PanelSurface and create a class called SynchronizedPanelSurface. As a parameter to the constructor, pass in an object that you will use to synchronize, call it "sync". Override the paint method in PanelSurface and wrap a call to super.paint(g) in a synchronized block using the sync object. Also, when you add and remove objects from the chart, wrap those calls in a synchronized block, using a reference to the same sync object. If you are going to go back to SWT, it's a bit more complicated, since the paint function isn't public.
2. Extract the code from the SimpleChart_1.1.1.jar and import it into Eclipse. Synchronize access to the chartObjects. Take a look at the version of LineChart on the CVS server to see how this was done in the new version. Be careful not to copy and paste too much of it, though, as a lot has changed.
This would also allow you to look into tweaking the x-axis and y-axis code to put up custom labels. Right now that's not supported in either version.
3. If you're going to start tweaking the code, you might want to just go ahead and work with the latest version. The ConcurrentModificationException bug has been fixed in the latest code. However, the x-axis and y-axis code need to be re-implemented because I've added the ability to rotate the chart, which broke the old implentation. SimpleChart (because some projects I am working on benefit from it) is turning into a general purpose 2D viewer. The x and y axis will become separate chart objects just like any other. If you wanted to, you could download the source and take a crack at writing some IChartObjects for the axes, complete with custom label support.
4. You could try slowing down the screen refresh rate, to a point where the concurrent modification exception doesn't occur. This is a pretty bad solution, I know.
5. You can look into JFreeChart, which supports custom labels and lots of other things that SimpleChart doesn't. I'm not sure how well it performs for these rapid updates, though -- it might be worse because you have less control over when a repaint occurs.
SimpleChart was meant to be something that you could get up and running with just a few lines of code and only one or two classes to learn how to use. JFreeChart takes a bit more time to learn, but its very popular.
As for the inefficiency of adding a few points to a large series - you're right, it might get to be too expensive. However, it seemed to me when I wrote the code that getting away with only updating part of the screen was a special case that added more complexity than it was worth. For instance, if the area of the chart needs to be changed to accomodate the new data, you have to redraw everything anyway. Also, unless you have a buffer for each individual chart object, a change to one object may require a redraw of the other chart objects, if that change would reveal a new part of the other chart object. The logic to determine what to update and when would have complicated the code considerably and would probably have been difficult to get right, so I compromised and broke everything into two buffers: the background (which consists of the axes, the legend, the title, and the blank chart area) and the foreground (which consists of the chart objects). If only the foreground changes, just the chart objects are redrawn. Otherwise, everything is redraw.
In the new version, I've added the concept of layers which can further reduce redrawing, but mainly they surve to get finer grained control over how objects should be ordered on the z-axis.
I may have some time to work on getting the axis problem solved in the CVS version. I'll post a note here if I do, but it might not be for a while.
Dan
P.S. Actually, there's one other option. I do have a version of the code that is after the threading fix, but before I added rotation, which means it should work for your purposes. I can look into posting it on sourceforge, or, for a much faster response, you could send me your e-mail address and I can attach a jar file. my e-mail is
dan dot phifer [at] gmail
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> 1. You could extend PanelSurface and create a class called SynchronizedPanelSurface.
> As a parameter to the constructor, pass in an object that you will use to synchronize,
You know, about a millisecond after I posted my last comment, the pattern of synchronizing the data series attribute came to mind (that's the definition of an 'ohno-second', right? The length of time between hitting the Return key and saying "Oh, no!"...).
But then I realized I didn't know what other class/method would participate in this pattern so I just went home and drank some beer....
> 5. You can look into JFreeChart, which supports custom labels and lots of other things
I have looked at JFreeChart as well as a few other open source packages. I'm working on a commercial package today. JFreeChart is really flexible, looks nice, lots of options, etc., but the renderer for dynamic charts is reeeeeally slow. Someone wrote a fast(er) renderer, and that helped to some degree, and I tweaked my usage of the plotter to only notify the renderer to update every three - four packets, but it was still pretty bad.
For example, both PtPlot and JChart2D can render four dynamic streams/traces at 64 Hz data sample rate and consume about 3 - 7% of my CPU. JFreeChart with the custom fast renderer takes 80 - 90% of my CPU. Ouch. My application is a DSP application and will have FFTs, filters, dynamic charts, frequency analyzers, etc. I can't afford to have a single dynamic trace consume 80% of one CPU....
Because of the various display options, I'll use SimpleChart or JFreeChart for static charting, but probably JChart2D for the dynamic stuff (unless this commercial package I'm testing today just blows JChart2D away).
> As for the inefficiency of adding a few points to a large series - you're right, it
> might get to be too expensive. However, it seemed to me when I wrote the code that
> getting away with only updating part of the screen was a special case that added more
> complexity than it was worth.
That's why I leave the development of renderers to people far smarter than me.... Me? I can optimize an FFT with the best of them, but graphics.... Nope.
Thanks for your immense help and sorry for my original foobar. I'll even help test the new version. Let me know. racernewbie at yahoo dot com .
r
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a nice package; I'm thinking of using it in my RCP application. However.....
1) I created a simple JFace-based application (extends ApplicationWindow) and just plopped a ChartComposite onto it. I then created a couple of Actions that plot the various example series found in the plugin. The data appears, but try as I might I cannot get the axis markers or titles to display. Hmmm. I can send my source code if you wish.... I'm using v 1.1.1 of SimpleChart
2) One of features of my application is a real-time line graph (updated every 15 ms) of up to four series, plus a histogram updated every second. The line graph would have fixed min n max values on the X n Y axises and would chart connected points from the left, fill to the right, clear the graph when the series was 'full', and then start over. Each clear-fill cycle would last about 5 - 10 seconds.
The histogram would display a summary of the real-time graph but updated every 1 second.
Can this toolkit do something like that?
First, thanks for trying out Simple Chart.
1)
As for your first question, I want to start with an obvious suggestion, just to make sure it isn't the problem, and then you can send
me a code snippet and I'll take a look at it.
Are you sure you are turning on the options to show the axis titles and markers?
getChart().setYAxisTitleVisible(true);
getChart().setYAxisVisible(true);
getChart().setXAxisTitleVisible(true);
getChart().setXAxisVisible(true);
getChart().setShowHorizontalGridLines(true);
getChart().setShowVerticalGridLines(true);
2) You can definately use Simple Chart for a real time graph. I'm doing that very thing in another application I'm working on. The best way I've found to do it is to remove the series you want to update and replace it with new series. You can turn autoZoom off and set the bounds yourself:
getChart().setAutoFitXAxis(false);
getChart().setAutoFitYAxis(false);
getChart().setZoomArea(0,0,100,100); // for example
It sounds inefficient, but you should find that it updates very fast, unless the chart takes up a lot of space on the screen.
I hope that helps, and feel free to post a code snippet.
Here's my Action class which updates the chart. The 'Util' class is just a singleton that holds the LineChart object. I'm using Elcipse 3.2.2, JDK 1.5.0_06 on a Linux (FD 7) system.
Is there a way I can send my ApplicationWindow wrapper (e.g. some ZIP file) other than UUENCODE'ing it and posting it here?
thanks.
r
<code>
public class Plot2Action extends Action {
ApplicationWindow window;
public Plot2Action (ApplicationWindow w) {
this.window = w;
setText ("Plot 2");
setToolTipText("Plot 2");
}
public void run() {
ChartHistogram h = new ChartHistogram("Series 3",
new int[]{10,9,8,7,6,5,6,7,6,5,4,3,2,1},
Color.GREEN,
true);
LineChart lc = Util.getChart();
boolean smoothZooming = lc.isSmoothZooming();
lc.setSmoothZooming(false);
// remove the existing chartObjects
lc.removeAllChartObjects();
// add the collection to the chart
lc.addChartObject(h);
lc.setLegendVisible(true);
lc.setXAxisLabel("XXX");
lc.setXAxisTitleVisible(true);
lc.setXAxisVisible(true);
lc.setYAxisLabel("YYY");
lc.setYAxisTitleVisible(true);
lc.setYAxisVisible(true);
lc.setBackground(Color.BLUE);
// repaint and reset the user zoom setting
lc.repaint();
lc.setSmoothZooming(smoothZooming);
}
}
</code>
I don't see anything wrong with the snippet you posted, so I'll need to try to reproduce it on my own. You can also send me an e-mail with a zip attached to my gmail.com address, dan.phifer. Also, attach a screen shot if you can.
I thought of a couple more things:
1. Does the example included with the package show the x and y axis labels/markers? You can toggle the x and y axis labels and markers in the drop down menu on the Line Chart view. (If you have Simplechart installed in eclipse, you can go to Window->Show View->Other... and open the two views under the Simplechart category). Also, if you are writing an RCP application, you can reuse the Line Chart view and pass it data via the selection framework in Eclipse.
2. Is it possble that the bottom of the chart is being cut off? You should see a white box around the chart area, a few pixels from the edge. Try alternating the boolean values for setXAxisTitleVisible each time the aciton is run, and see if the chart shifts up and down.
I'll take a look at it tonight or tomorrow after work.
Dan
I can't seem to reproduce the problem. I've attached some code that I created to test it out. Here's the steps I used to get it running:
1. Downloaded Simplechart 1.1.1 and extracted SimpleChart_1.1.1.jar to my desktop
2. Created a new Plug-in project in eclipse (so all of the jface/swt dependencies would be set up for me)
3. Went into project properties and added the SimpleChart_1.1.1.jar to my project my clicking "Add External JARs..."
4. Create a new Class (included below) that extends ApplicationWindow
The class has an inner class that implements the action you included. Apologies if this is not readed by the sourceforge server in a friendly manner:
/*
* Created on Feb 17, 2008
*/
package testswtchart2;
import java.awt.Color;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import widgets.ChartComposite;
import chart.ChartHistogram;
import chart.LineChart;
/**
* @author Dan Phifer
*/
public class Main
{
/**
* @param args
*/
public static void main(String[] args)
{
Display display = Display.getDefault();
Shell shell = new Shell(display);
ApplicationWindow w = new MyApp(shell);
w.setBlockOnOpen(true);
w.open();
}
public static class MyApp extends ApplicationWindow
{
private LineChart lc;
public MyApp(Shell parentShell)
{
super(parentShell);
addToolBar(SWT.FLAT);
getToolBarManager().add(new Plot2Action(this));
}
@Override
protected Control createContents(Composite parent)
{
ChartComposite c = new ChartComposite(parent, SWT.NONE);
parent.setSize(500, 300);
lc = c.getChart();
return parent;
}
@Override
protected Control createToolBarControl(Composite parent)
{
Control c = super.createToolBarControl(parent);
return c;
}
public class Plot2Action extends Action
{
ApplicationWindow window;
public Plot2Action(ApplicationWindow w)
{
this.window = w;
setText("Plot 2");
setToolTipText("Plot 2");
}
public void run()
{
ChartHistogram h = new ChartHistogram("Series 3",
new int[] { 10, 9, 8, 7, 6, 5, 6, 7, 6, 5, 4, 3, 2, 1 }, Color.GREEN, true);
boolean smoothZooming = lc.isSmoothZooming();
lc.setSmoothZooming(false);
// remove the existing chartObjects
lc.removeAllChartObjects();
// add the collection to the chart
lc.addChartObject(h);
lc.setLegendVisible(true);
lc.setXAxisLabel("XXX");
lc.setXAxisTitleVisible(true);
lc.setXAxisVisible(true);
lc.setYAxisLabel("YYY");
lc.setYAxisTitleVisible(true);
lc.setYAxisVisible(true);
lc.setBackground(Color.BLUE);
// repaint and reset the user zoom setting
lc.repaint();
lc.setSmoothZooming(smoothZooming);
}
}
}
}
Sorry for not responding earlier. Boss had me work some other project for a bit. Darn bosses... Oh, wait, I'm the boss.....
My Eclipse project is a bit different, I just extracted the source from CVS from SourceForge. I get the same problem (no axes) when I run your example above. I'll try a couple of different things, as well. Also, I'm running Eclipse 3.2.2 on a Linux system (JDK 1.5.0_06?).
I see the legend in the plot and I can successfully enable/disable the display of that, but no axes...
Lemme try a couple of other things this afternoon....
r
Got it to work. I started with the SimpleChart JAR instead of the source from CVS. My bad.
Okay, now about that dynamic charting capability..... I'll work on that, now.
r
Ah, that makes sense. I thought you were using v1.1.1
Yeah, the code from CVS is, well, in a state of change right now. I'm working on what I guess will be version 2.0. Sorry there's no branch.
K. I tried to get a dynamic chart working. Here are the specifics:
I have (essentially) a time-series chart. The data is in refreshed 64Hz cycles (from a data collection device). Each cycle contains four data points. Each data message contains up to eight series of data.
My display class does:
<precondition>
float[] data = new float [maxXValue];
int xValue =0;
chart.addSeries ("name", data, color, false);
</precondition>
For each cycle I do the following:
<code>
msgData = retrieveData(); // blocking - returns after 15.6 ms
chart.removeChartObject (trace);
for (idx=0; idx < 4; idx++) {
data[xValue] = msgData[idx];
xValue++;
}
trace = chart.addSeries ("name", data, color, false);
chart.repaint();
if (xValue > maxXValue) {
xValue = 0;
}
</code>
This works for about 11 cycles and then I get the following traceback almost every cycle:
Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
at java.util.AbstractList$Itr.next(AbstractList.java:420)
at chart.LineChart.drawChartObjects(LineChart.java:650)
at chart.LineChart.updateChart(LineChart.java:393)
at chart.LineChart.paint(LineChart.java:174)
at widgets.PanelSurface.notifyPaintListeners(PanelSurface.java:119)
at widgets.PanelSurface.paint(PanelSurface.java:94)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Also, the definition of a data series is a bit light for my application. My X axis is a time series and I would like to display time intervals (e.g., "00:05", "00:10") as the labels.
Plus, adding a small set of data to a series is a bit odd as it appears the LineChart draws all elements in the yValues array and if I want to add 1 - 4 points to a series that could display 10K elements would get ugly.....
I'll keep trying.
r
Hmmm. The concurrent modification exception is because the repaint is still happening when trace is removed from the chart. This is a bug that I've fixed in the new version.
There are a number of options, but I'm not sure you'll like any of them:
1. You could extend PanelSurface and create a class called SynchronizedPanelSurface. As a parameter to the constructor, pass in an object that you will use to synchronize, call it "sync". Override the paint method in PanelSurface and wrap a call to super.paint(g) in a synchronized block using the sync object. Also, when you add and remove objects from the chart, wrap those calls in a synchronized block, using a reference to the same sync object. If you are going to go back to SWT, it's a bit more complicated, since the paint function isn't public.
2. Extract the code from the SimpleChart_1.1.1.jar and import it into Eclipse. Synchronize access to the chartObjects. Take a look at the version of LineChart on the CVS server to see how this was done in the new version. Be careful not to copy and paste too much of it, though, as a lot has changed.
This would also allow you to look into tweaking the x-axis and y-axis code to put up custom labels. Right now that's not supported in either version.
3. If you're going to start tweaking the code, you might want to just go ahead and work with the latest version. The ConcurrentModificationException bug has been fixed in the latest code. However, the x-axis and y-axis code need to be re-implemented because I've added the ability to rotate the chart, which broke the old implentation. SimpleChart (because some projects I am working on benefit from it) is turning into a general purpose 2D viewer. The x and y axis will become separate chart objects just like any other. If you wanted to, you could download the source and take a crack at writing some IChartObjects for the axes, complete with custom label support.
4. You could try slowing down the screen refresh rate, to a point where the concurrent modification exception doesn't occur. This is a pretty bad solution, I know.
5. You can look into JFreeChart, which supports custom labels and lots of other things that SimpleChart doesn't. I'm not sure how well it performs for these rapid updates, though -- it might be worse because you have less control over when a repaint occurs.
SimpleChart was meant to be something that you could get up and running with just a few lines of code and only one or two classes to learn how to use. JFreeChart takes a bit more time to learn, but its very popular.
As for the inefficiency of adding a few points to a large series - you're right, it might get to be too expensive. However, it seemed to me when I wrote the code that getting away with only updating part of the screen was a special case that added more complexity than it was worth. For instance, if the area of the chart needs to be changed to accomodate the new data, you have to redraw everything anyway. Also, unless you have a buffer for each individual chart object, a change to one object may require a redraw of the other chart objects, if that change would reveal a new part of the other chart object. The logic to determine what to update and when would have complicated the code considerably and would probably have been difficult to get right, so I compromised and broke everything into two buffers: the background (which consists of the axes, the legend, the title, and the blank chart area) and the foreground (which consists of the chart objects). If only the foreground changes, just the chart objects are redrawn. Otherwise, everything is redraw.
In the new version, I've added the concept of layers which can further reduce redrawing, but mainly they surve to get finer grained control over how objects should be ordered on the z-axis.
I may have some time to work on getting the axis problem solved in the CVS version. I'll post a note here if I do, but it might not be for a while.
Dan
P.S. Actually, there's one other option. I do have a version of the code that is after the threading fix, but before I added rotation, which means it should work for your purposes. I can look into posting it on sourceforge, or, for a much faster response, you could send me your e-mail address and I can attach a jar file. my e-mail is
dan dot phifer [at] gmail
Thanks again for the quick response.
> 1. You could extend PanelSurface and create a class called SynchronizedPanelSurface.
> As a parameter to the constructor, pass in an object that you will use to synchronize,
You know, about a millisecond after I posted my last comment, the pattern of synchronizing the data series attribute came to mind (that's the definition of an 'ohno-second', right? The length of time between hitting the Return key and saying "Oh, no!"...).
But then I realized I didn't know what other class/method would participate in this pattern so I just went home and drank some beer....
> 5. You can look into JFreeChart, which supports custom labels and lots of other things
I have looked at JFreeChart as well as a few other open source packages. I'm working on a commercial package today. JFreeChart is really flexible, looks nice, lots of options, etc., but the renderer for dynamic charts is reeeeeally slow. Someone wrote a fast(er) renderer, and that helped to some degree, and I tweaked my usage of the plotter to only notify the renderer to update every three - four packets, but it was still pretty bad.
For example, both PtPlot and JChart2D can render four dynamic streams/traces at 64 Hz data sample rate and consume about 3 - 7% of my CPU. JFreeChart with the custom fast renderer takes 80 - 90% of my CPU. Ouch. My application is a DSP application and will have FFTs, filters, dynamic charts, frequency analyzers, etc. I can't afford to have a single dynamic trace consume 80% of one CPU....
Because of the various display options, I'll use SimpleChart or JFreeChart for static charting, but probably JChart2D for the dynamic stuff (unless this commercial package I'm testing today just blows JChart2D away).
> As for the inefficiency of adding a few points to a large series - you're right, it
> might get to be too expensive. However, it seemed to me when I wrote the code that
> getting away with only updating part of the screen was a special case that added more
> complexity than it was worth.
That's why I leave the development of renderers to people far smarter than me.... Me? I can optimize an FFT with the best of them, but graphics.... Nope.
Thanks for your immense help and sorry for my original foobar. I'll even help test the new version. Let me know. racernewbie at yahoo dot com .
r