Using JFREECHART API , I developed an timeSeries graph. It worked fine. Then I updated model data. i.e. I kept adding items in model data at periodic intervals say 1 or 3 secs. Even view has got updated properly. But view has updated with in the default drawable area (say 600* 400). So when I keep on adding data , it appeared in a cramped state. Is there is a possibity to incorporate an Scroll Pane. So that chart area gets extended and user should be able to view the graph entirely i.e. meaning that chart area should get grow and viewport should be shifted to latest plotted region. And graph has to maintain uniform distance between grids.
Herewith I have attached my source code.
import com.jrefinery.data.*;
import com.jrefinery.chart.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
public class MyTimeChart extends TimerTask
{
TimeSeriesCollection model = null;
long period = 0;
Plot pl = null;
BasicTimeSeries s1;
BasicTimeSeries s2;
public MyTimeChart (String[] args)
{
// create a chart...
model = createDataset();
JFreeChart chart = ChartFactory.createTimeSeriesChart("Karthick Sample Line Chart", "CATEORY","AXIS", model, true);
pl = chart.getPlot();
DateAxis xax = (DateAxis)(((XYPlot)pl).getHorizontalValueAxis());
xax.setTickUnit( new DateUnit(Calendar.SECOND,5));
// create and display a frame...
JFrame frame = new JFrame();
ChartPanel chartPanel = new ChartPanel(chart,500,300,400,200,5000,500,true, true, true, true, true, true );
chartPanel.setMouseZoomable(true,true);
frame.getContentPane().add(new JScrollPane(chartPanel));
frame.setSize(700,200);
frame.setVisible(true);
try
{
int seconds = Integer.parseInt(args[0]);
period = seconds * 1000;
}
catch(Exception e)
{
e.printStackTrace();
}
schedule();
}
int counter = 0;
public TimeSeriesCollection createDataset() {
s1 = new BasicTimeSeries("L&G European Index Trust", Second.class);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 181.

s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 167.3);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 153.

s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 167.6);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 158.

s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 148.3);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 153.9);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 142.7);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 123.2);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 131.

s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 139.6);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 142.9);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 138.7);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 137.3);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 143.9);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 139.

s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))) , 137.0);
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 132.

counter = 0;
s2 = new BasicTimeSeries("L&G UK Index Trust", Second.class);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 181.

s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 129.6);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 123.2);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 117.2);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 124.1);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 122.6);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 119.2);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 116.5);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 112.7);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 101.5);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 106.1);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 110.3);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 111.7);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 111.0);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 109.6);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 113.2);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 111.6);
s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 108.

s2.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), 101.6);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
return dataset;
}
private void schedule()
{
java.util.Timer timer = new java.util.Timer();
timer.schedule(this,0,period);
}
int inc = 10;
boolean test = true;
public void run()
{
Random rd =new Random();
System.out.println("SCHEDULED");
try
{
s1.add(new Second(new Date(System.currentTimeMillis() + ((++counter)*1000))), rd.nextDouble()*150);
s2.add(new Second(new Date(System.currentTimeMillis() + ((counter)*1000)+500)), rd.nextDouble()*150);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
new MyTimeChart(args);
}
}// MyTimeChart
Thanks & regards,
S.Karthick