Using the latest code from CVS, I have created an OverlaidXYPlot as follows:
OverlaidXYPlot overlaid_plot = new OverlaidXYPlot(X_AXIS_LABEL, Y_AXIS_LABEL);
overlaid_plot.setDomainAxis(x_axis);
XYSeriesCollection time_series_data = ...
TimeSeriesToolTipGenerator ttg_1 = new TimeSeriesToolTipGenerator("d-MMM-yyyy", "0.00");
XYItemRenderer renderer_1 = new StandardXYItemRenderer(StandardXYItemRenderer.LINES, ttg_1);
XYPlot subplot_1 = new XYPlot(time_series_data, null, null, renderer_1);
overlaid_plot.add(subplot_1);
XYSeriesCollection scatter_data = ...
TimeSeriesToolTipGenerator ttg_2 = new TimeSeriesToolTipGenerator("d-MMM-yyyy", "0.00");
XYItemRenderer renderer_2 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, ttg_2);
XYPlot subplot_2 = new XYPlot(scatter_data, null, null, renderer_2);
overlaid_plot.add(subplot_2);
chart = new JFreeChart(CHART_TITLE, JFreeChart.DEFAULT_TITLE_FONT, overlaid_plot, true);
JFreeChartPanel chart_panel = new JFreeChartPanel(chart, true, false, true, true, true);
============
Zoom --
Is it expected that zoom will ever be implemented for
OverlaidXYPlots?
=========
Dynamic updates -- If the frame is visible while the two data sources are being updated by another thread, the line data in the first plot is dynamically updated but the shape data from the second plot is never drawn unless the frame is closed and reopened. What listener do I have to tie in to get the second plot to update when the data changes?
As a side comment, it seems that a few people in the forum have used overlaid plots for the situation where they want to draw a line for one series and shapes for all of the other data series. At one point it was suggested that a separate renderer for each series was being considered. I think many cases would be covered if it were just possible to specify the specific shape or line for a single instance of a renderer to use for each data series. Then we could tell the renderer to use a line for series 1, square shapes for series 2, triangles for series 3, etc. Possibly the hard dicotomy between lines and shapes should go away and lines should just be a specialization of shape with its own draw behavior.
OverlaidXYPlot zoom and live update
Re: OverlaidXYPlot zoom and live update
ZOOMING:
If you delete the empty zoom method in OverlaidXYPlot and set the zoom flag in the JFreeChartPanel constructor to true, then the zooming works just as it does for XYPlot. Now that OverlaidXYPlot is an extension of XYPlot, there's no need to override the zoom method, so I've removed it (I'll commit the change to CVS today).
Zooming on MultiXYPlot will be slightly more difficult, it will be easy to zoom the shared axis...but I'm not sure whether the non-shared axes on the subplots should:
1) not zoom at all;
2) zoom in tandem;
3) zoom only if the popup menu is selected within the subplot (i.e. each axis can be zoomed independently).
I think 3 is best, but the code will need some work.
DYNAMIC UPDATES:
I'm not sure that I've got the message notification working properly yet. I think in some cases, the notifications are being missed and in other cases there are too many notifications happening.
Each subplot should be listening to its own dataset for changes. When a data change notification is received, the axes may require updating and the parent plot needs to get the message so that it can notify its listeners (by default, the top level JFreeChart object). If you put a chart in a JFreeChartPanel, the panel listens for changes to the chart, and repaints the whole chart any time anything changes. Something must be failing in the chain if your chart is not updating correctly.
SHAPES v LINES
The main reason I've done the lines separately from the shapes is that to draw a shape you only need the x, y coordinate of the current data point, but to draw a line you need the x, y coordinate of the previous point also. And also you then have the option to have shapes and lines together.
I'll probably see how the new OverlaidXYPlot class settles before I revisit the idea of specifying a different renderer for each series in an XYPlot. My gut feeling is that the code would have similar complexity to the OverlaidXYPlot class and achieve the same thing...so it probably isn't necessary. But I'll listen to other opinions...
Regards,
DG.
If you delete the empty zoom method in OverlaidXYPlot and set the zoom flag in the JFreeChartPanel constructor to true, then the zooming works just as it does for XYPlot. Now that OverlaidXYPlot is an extension of XYPlot, there's no need to override the zoom method, so I've removed it (I'll commit the change to CVS today).
Zooming on MultiXYPlot will be slightly more difficult, it will be easy to zoom the shared axis...but I'm not sure whether the non-shared axes on the subplots should:
1) not zoom at all;
2) zoom in tandem;
3) zoom only if the popup menu is selected within the subplot (i.e. each axis can be zoomed independently).
I think 3 is best, but the code will need some work.
DYNAMIC UPDATES:
I'm not sure that I've got the message notification working properly yet. I think in some cases, the notifications are being missed and in other cases there are too many notifications happening.
Each subplot should be listening to its own dataset for changes. When a data change notification is received, the axes may require updating and the parent plot needs to get the message so that it can notify its listeners (by default, the top level JFreeChart object). If you put a chart in a JFreeChartPanel, the panel listens for changes to the chart, and repaints the whole chart any time anything changes. Something must be failing in the chain if your chart is not updating correctly.
SHAPES v LINES
The main reason I've done the lines separately from the shapes is that to draw a shape you only need the x, y coordinate of the current data point, but to draw a line you need the x, y coordinate of the previous point also. And also you then have the option to have shapes and lines together.
I'll probably see how the new OverlaidXYPlot class settles before I revisit the idea of specifying a different renderer for each series in an XYPlot. My gut feeling is that the code would have similar complexity to the OverlaidXYPlot class and achieve the same thing...so it probably isn't necessary. But I'll listen to other opinions...
Regards,
DG.