Results 1 to 10 of 10

Thread: Help! A basic graph to show a heart rate?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Posts
    4

    Question

    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

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    I'd use pset on a picturebox to do it.

    - jamie
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Posts
    4

    Question

    How do I use pset? My data is sitting in a collection, but I've never done any graphics drawing before in vb...

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Well here's a quick 'n easy example ;

    This assumes you have a picture box called Picture1 on your form ...

    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
    The basic format (that you have to worry about anyway) of PSet is :

    Code:
    object.PSet (x, y), [color]
    If you have any more questions, just let me know.

    - jamie
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Posts
    4

    kinda working... overflow error

    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

  6. #6
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Well if you attach your entire project zipped I'll see if I can help ...

    - jamie
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  7. #7
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Thats an interestign looking project you've attached there

    - jamie
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  8. #8

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Posts
    4

    moving along slowly

    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?

  9. #9
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Well as I dont know what you're actually doing exactly thats rather difficult ....
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  10. #10
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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!
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width