Plotting a graph using Java Applet

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-14 01:09:15

问题


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, 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).


回答1:


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.



来源:https://stackoverflow.com/questions/5210615/plotting-a-graph-using-java-applet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!