Hi, I would like to know how to take the input values from a CSV file into a java file
in eclipse for plotting a graph which would allow us real time programming .

For example:
Y axis(No of packets sent): 20 55 75 89
X axis (time): 2 2.30 3 3.30

I have installed eclipse. i found a code, in this it randomly plots the graph with respect to current
time.I would like to take the inputs from CSV file and plot the graph dynamically.
Could anyone guide me with this.


import java.util.Random;
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.time.Millisecond;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;

public class Main {

static TimeSeries ts = new TimeSeries("data", Millisecond.class);

public static void main(String[] args) throws InterruptedException {
gen myGen = new gen();
new Thread(myGen).start();

TimeSeriesCollection dataset = new TimeSeriesCollection(ts);
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"GraphTest",
"Time",
"Number of Packets",
dataset,
true,
true,
false
);
final XYPlot plot = chart.getXYPlot();
ValueAxis axis = plot.getDomainAxis();
axis.setAutoRange(true);
axis.setFixedAutoRange(60000.0);

JFrame frame = new JFrame("GraphTest");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
ChartPanel label = new ChartPanel(chart);
frame.getContentPane().add(label);
//Suppose I add combo boxes and buttons here later

frame.pack();
frame.setVisible(true);
}

static class gen implements Runnable {
private Random randGen = new Random();

public void run() {
while(true) {
int num = randGen.nextInt(1000);
System.out.println(num);
ts.addOrUpdate(new Millisecond(), num);
try {
Thread.sleep(20);
} catch (InterruptedException ex) {
System.out.println(ex);
}
}
}
}

}

Thankyou