The use of scale when making af 2D plot
- From: Nigo <nikolajkyndbyholm@xxxxxxxxx>
- Date: Thu, 27 Sep 2007 14:44:13 -0000
Hi there
I'm trying to draw a simple 2D graph (tried MSChart and it doesn't do
the trick for me) using simple line-commands.
The graph is 470x470 pixels and has top left corner in (104,24) pixels
on my form. I thought pixels would be nice to use as scalemode as its
supposed to work on many different screen res. even down to 600x800
(!)
The data I want to plot is contained in an array with a maximum size
of 470, corresponding to 1 datapoint pr pixel in the x-dimension of
the graph. The y-values are normalized to be in a range between 0 and
10, so there will be 47 pixel pr unit in the y-dimension. There will
be no negative values of either x or y, and I want the y-dimension
reversed so that increasing y-values would "go up" on the graph
(opposite to how its defined in VB with 0 being on the top and 500 at
the bottom of the form).
Because of the position and size of the 2D plot on the form, the
origon of the graph is placed at position (104,494) pixels on the
form.
Googling, reading and trying what I read about scale (x1,y1)-(x2,y2)
doesn't help me at all. It just makes me more confused, because typing
in what I would expect to be right creates strange results.
So please help me - what should be the values of x1, x2, y1 and y2 in
the following? Or is there a better way to solve it?
Public Sub DrawSignal(dataserie() As Single)
Dim x1 As Single, x2 As Single, y1 As Single, y2 As Single
Cls
Scale (x1,y1)-(x2,y2)
DrawWidth = 1
For x1 = LBound(dataserie) To UBound(dataserie)
x2 = x1 + 1
y1 = dataserie(x1)
If x1 < UBound(dataserie) Then y2 = dataserie(x1 + 1)
Line (x1, y1)-(x2, y2), vbRed
Next x1
End Sub
.
- Follow-Ups:
- Re: The use of scale when making af 2D plot
- From: Mike Williams
- Re: The use of scale when making af 2D plot
- Prev by Date: Re: Interprocess communications (across a network). [Long]
- Next by Date: Re: Computers are amazing
- Previous by thread: how convert vc++ code into vb?
- Next by thread: Re: The use of scale when making af 2D plot
- Index(es):
Relevant Pages
|