Please have a look into the demo(I derived from java2s.com as actually am running sim. stuff through bean shell script) . Do not know why zooming is slow . as the no. of plots increases zooming becomes slower and slower. and for 155 plots it just responds after a minute!!
can I make it faster. same response time for key and mouse listener also.
Code: Select all
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.*;
import org.jfree.data.general.SeriesException;
import org.jfree.data.time.Day;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.chart.plot.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.labels.*;
import org.jfree.chart.renderer.xy.*;
import java.awt.*;
import javax.swing.*;
public class TimeSeriesDemo5 extends ApplicationFrame {
public TimeSeriesDemo5(final String title) {
super(title);
NumberAxis xAxis = new NumberAxis("PLOT_COMMON_X_AXIS_NAME");
CombinedDomainXYPlot combPlot = new CombinedDomainXYPlot(xAxis);
combPlot.setDataset(null);
combPlot.setGap(5.0);
combPlot.setBackgroundPaint(Color.lightGray);
combPlot.setDomainGridlinePaint(Color.white);
combPlot.setRangeGridlinePaint(Color.white);
String[] POWClockFreqT = new String[]
{ "OFF", "ON", "32K","2M","3_25M","6_5M","8_67M","13M","26M","27M","31_2M",
"33_3M","39M","44_5M","48M","52M","78M","89M", "96M","104M","108M","124_8M",
"133_25M", "138670K","156M", "178M","208M","312M","416M"
};
SymbolAxis yAxis0 = new SymbolAxis("PLOT_0_Y_AXIS_NAME",POWClockFreqT);
TimeSeriesCollection dataCollection0 = new TimeSeriesCollection();
dataCollection0.addSeries(createDataseries());
XYToolTipGenerator toolTip = new StandardXYToolTipGenerator();
final int PLOT_STYLE = StandardXYItemRenderer.LINES;
StandardXYItemRenderer renderer = new StandardXYItemRenderer( PLOT_STYLE);
renderer.setBaseToolTipGenerator( toolTip );
XYPlot plot0 = new XYPlot(dataCollection0, xAxis, yAxis0, renderer);
for (int i=1;i<21;i++)
{
combPlot.add(plot0,i);
}
final JFreeChart chart = new JFreeChart("CHART_NAME", JFreeChart.DEFAULT_TITLE_FONT, combPlot, true);
combPlot.setOrientation(PlotOrientation.VERTICAL);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize( new Dimension( 1250, 300*20 ) );//10000
JScrollPane scrollPane = new JScrollPane(chartPanel);
chartPanel.setMouseZoomable(true, false);
setContentPane(scrollPane);
}
private TimeSeries createDataseries() {
final TimeSeries series = new TimeSeries("Random Data");
Day current = new Day(1, 1, 1990);
double value = 100.0;
for (int i = 0; i < 100; i++) {
try {
value = value + Math.random() - 0.5;
series.add(current, new Double(value));
current = (Day) current.next();
}
catch (SeriesException e) {
System.err.println("Error adding to series");
}
}
return series;
}
public static void main(final String[] args) {
final String title = "Title";
final TimeSeriesDemo5 demo = new TimeSeriesDemo5(title);
demo.pack();
RefineryUtilities.positionFrameRandomly(demo);
demo.setVisible(true);
}
}
I overridden ChartPanel class for my need so scaling is not an issue and plot doesn't looks stretched.
One more info there are approx. 100*155(100 points per subplot) points in my entire CombinedDomainXYPlot. do not know is that is the reason ???
