Click to See Complete Forum and Search --> : Help! A basic graph to show a heart rate?
ti_pin_man
Mar 12th, 2001, 05:16 AM
I need help (in more way than one), I'm basically looking to build my own graph using data from values held in a collection. Its for illustrating a heart rate and therefore not a bar or pie chart one! Anybody any clues?
Thanks
Joe
plenderj
Mar 12th, 2001, 05:49 AM
I'd use pset on a picturebox to do it.
- jamie
ti_pin_man
Mar 31st, 2001, 05:28 AM
How do I use pset? My data is sitting in a collection, but I've never done any graphics drawing before in vb...
plenderj
Apr 2nd, 2001, 02:11 AM
Well here's a quick 'n easy example ;
This assumes you have a picture box called Picture1 on your form ...
Option Explicit
Private i As Long
Private Sub Form_Load()
Picture1.AutoRedraw = True
For i = 0 To 1000
Picture1.PSet (Rnd * Picture1.Width, Rnd * Picture1.Height), vbRed
Next i
End Sub
The basic format (that you have to worry about anyway) of PSet is :
object.PSet (x, y), [color]
If you have any more questions, just let me know.
- jamie
ti_pin_man
Apr 4th, 2001, 03:45 AM
This was my eventual solution, kinda based on your help (and a book!):
CODE:*********************
'*****Display Graph*****
Private Sub cmdShort_click()
Dim X As Long '1st read
Dim Y As Long '1st Read
Dim X1 As Long '2nd Read
Dim Y1 As Long '2nd Read
Dim Xmax As Long
Dim Xmin As Long
Dim Ymax As Long
Dim Ymin As Long
Dim Ymid As Long
'Dim Minute As Integer
'Minute = 7680
Dim i As Long
Dim plot As Long
Dim Yinc As Long
X = picGraph.Width
Y = picGraph.Height
Xmax = (X / 100) * 90
Xmin = (X / 100) * 10
Ymax = (Y / 100) * 10
Ymin = (Y / 100) * 90
'set up Ymid line
Ymid = Ymax + ((Ymin - Ymax) / 2)
'draw Axis
picGraph.Line (Xmin, Ymid)-(Xmax, Ymid)
picGraph.Line (Xmin, Ymin)-(Xmin, Ymax)
'set up increments along Y axis
Yinc = (Ymid - Ymax) / 2000
'initialise variables
i = 1
plot = 1
'read edge variable
Call sobelA.Item(plot)
'assign edge variable to X & Y
Y = Ymid - (plot * Yinc)
X = Xmin
PSet (X, Y)
For i = 1 To sobelA.Count
'Call sobelA.Item(plot)
Y1 = Ymid - (sobelA.Item(plot) * Yinc)
X1 = Xmin + i
'Print sobelA.Item(plot)
picGraph.Line (X, Y)-(X1, Y1)
plot = plot + 1
X = X1
Y = Y1
Next i
The only problem now is that in processing the collection of values there are 7960*30 minutes of data to process. This causes an overflow .... problems problems! ;-)
Joe
plenderj
Apr 4th, 2001, 04:07 AM
Well if you attach your entire project zipped I'll see if I can help ...
- jamie
plenderj
Apr 5th, 2001, 02:06 AM
Thats an interestign looking project you've attached there ;)
- jamie
ti_pin_man
Apr 5th, 2001, 10:33 AM
Hhhhmmmm, "interesting" actually a bit of a pain in the ... anyway I've moved on a little and am know just normalising the data in minute chunks rather than processing the whole file. I need to work out my loops a little.
Did you have any suggestions?
plenderj
Apr 5th, 2001, 10:47 AM
Well as I dont know what you're actually doing exactly thats rather difficult ....
Jotaf98
Apr 5th, 2001, 10:51 AM
Maybe you should compress the file a bit. It's not that hard. You could, for example, instead of keeping the value in every frame, do it only when it changes! Like... the player loses 10hp, so you add to the file the hp lost and the time distance from the last time the hp changed. You'll probably notice the file size decrease from 3mb to something like 3kb ;)
You should also draw it AS YOU READ THE FILE, that means DON'T KEEP IT IN MEMORY! It's just too big!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.