Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create graph from data in text file

Status
Not open for further replies.

Wrathchild

Technical User
Aug 24, 2001
303
US
Is it possible for me to read in data from a text file via a buffered reader, then graph that data? I can do the first part, but need help with the graphing.

thanks!
 
Have a look at the JFreeChart API, its very good.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
thanks guys, I'm just looking to graph some numbers, nothing fancy, just for a project at school.

I don't have anything written yet, but I've read data in from a text file before so I can just reuse that part.
 
JFreeChart is good but it is difficult for beginner.
It uses Swing and the program is difficult to trace.
 
Not that I'm a great Java programmer but I did a little thing like you're describing. In my case, I wanted to graph some X,Y data from a comma-separated-values text file (where each line in the file is x,y). I graph the values with "x"s and compute a linear least squares and plot that line (as a line). Alternatively, I suppose you could plot the lines between the "x"s as lines.

The whole code is a little long (275 lines) and of no interest to anyone on this forum but I'd be happy to send it to you. I only use AWT classes as I use this app. on a PDA, so it's pretty basic. The salient features, after computing the scales (so it fits on the canvas) are:

a canvas
c1 = new Canvas();
a graphics class
private static Graphics g1;
g1 = c1.getGraphics();

and draw a string or draw a line
g1.drawString("x",(int)x2,chgt-6-(int)y2);
g1.drawLine((int)x1,chgt-6-(int)y1,(int)x2,chgt-6-(int)y2);



_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top