Plotting a graph using Java Applet
I have a problem where I have to draw a graph on an applet using some data in an excel file. I would need to design an applet where I can display the graph and the data on the same applet.
I had a hard time writing some code in Java to code some CSVreader and ExcelReader files. Now,开发者_JS百科 I am really stuck in how to take this data and graph it on an applet.
I don't know which class/libraries to use for drawing the graph and how to scale it and draw the actual points or designing the applet itself. I would appreciate if someone can help me out.
EDIT
Sample input:
mis(t) nt Vt N(t) h(t) H(t)
1 141 200,000 200,000 0.00071 0.00071
2 103 200,000 199,859 0.00052 0.00122
Here, the graph is to be plotted for mis(t)
vs. h(t)
.
Perhaps, what you are looking for is an easy to use Chart application in Java. The answer is jFreeChart. They have a lots of samples as well to get you started immediately.
And regarding reading CSV files to pass the data to jFreeChart, use OpenCSV
Reading a CSV file is as simple as -
CSVReader rec = new CSVReader(new FileReader(filePath));
String[] recLine;
while ((recLine = rec.readNext()) != null) {
//Get the data from recLine
}
Let me know if you need more details.
精彩评论