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
Printable View
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
I'd use pset on a picturebox to do it.
- jamie
How do I use pset? My data is sitting in a collection, but I've never done any graphics drawing before in vb...
Well here's a quick 'n easy example ;
This assumes you have a picture box called Picture1 on your form ...
The basic format (that you have to worry about anyway) of PSet is :Code: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
If you have any more questions, just let me know.Code:object.PSet (x, y), [color]
- jamie
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
Well if you attach your entire project zipped I'll see if I can help ...
- jamie
Thats an interestign looking project you've attached there ;)
- jamie
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?
Well as I dont know what you're actually doing exactly thats rather difficult ....
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!