A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Dec 29, 2004
Jan 07, 2005 07:01:00
can anyone give me the basic
code to create a simple line graph for my java program output.
thanks a lot in advance.
Joined: May 20, 2004
Feb 01, 2005 10:47:00
Well i cant give you the code but maybe u can use this suggestion.
Java considers the upper left hand corner as 0,0 whereas your graph could have the 0,0 at java's 50,50 or any other such co-ordinate.
What you can do is first of all treat X axis and Y axis individually.
To get a point in java consider this simple example
Suppose you have an
of size 100 x 100. So arbitarily i decide to take 50,50 as the origin of the graph.
Now, draw a horizontal line from 0,50 to 100,50 (of Java) as X Axis and a vertical line from 50,0 to 50,100 as Y axis.
Now if the first point in XY Co-ordinates is 10,20 Then establish the point as (50+10),(50-20) on the canvas's co-ordinates. Similarly, point 30,0) will be 80,50 on the canvases Coordinates.
I hope that helped.
It is sorta covered in the
JavaRanch Style Guide
Java to XML
WA #2 ..... word association
Graph in java
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014