|
-
Jan 10th, 2010, 07:31 AM
#17
Re: [RESOLVED] Converting voltage level into graphical display
 Originally Posted by catherine0136
[CODE] i replace the ( , ) value to the values of where the x and y line intersect each other ?
Exactly.
Code:
g.DrawLine(BluePen, 50, 120, 260, 120) 'horizontal line
If that line is your X axis, it extends from point (50, 120) to point (260, 120), so must be 210 pixels long. You could fill in that 210 everywhere instead of xAxisLength, but it would be better to keep using the variable name instead:
vb.net Code:
Dim xAxisLength As Integer = 210 'and then, as before: x = Origin.X + CInt(i * xAxisLength / 40)
The same obviously applies to the Y axis. This way there is just one place where you set the axis length. It will be easier to change you layout if you need to. After all, you may need to play around with these figures to get the graph looking right.
You realize of course that xAxisLength is just a name I made up. An important part of the art of programming is thinking up good names for variables. To come to think of it, it would be better to replace that "40" by a variable to represent the number of data points to be plotted. In that case you would have to declare (with Dim or Private) whatever name you have chosen for the variable. You should do it outside the sub, for example with other variables near the top of the form code, because it is also referred to in the timer Tick sub.
BB
Last edited by boops boops; Jan 10th, 2010 at 07:49 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|