4

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
  • Can u provide a sample data row? To be honest drawing in Java is all about overriding the public void paint(Graphics g) method and from there on start using the Graphics object to draw anything u want. Concerning the scaling u would divide the points by some constant that would make the graph as small as required to fit in your applet. Commented Mar 6, 2011 at 13:08

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.