Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleDraw a continuous graph similiar to perfmon in VB .NET
Keywordsgraph, continuous graph, scroll, perfmon
CategoriesGraphics, VB.NET
 
When a timer event executes, use PaintPicture to move the existing graph left. Clear the area on the right, restore its guide lines, and draw the new data.

Note that this code uses two transformations to make the PictureBox's coordinates increase from bottom to top.

 
Private Sub tmrGraph_Tick(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles tmrGraph.Tick
    ' Move the old data over.
    Dim bm As New Bitmap(picGraph.Width, picGraph.Height)
    Dim gr As Graphics = Graphics.FromImage(bm)
    gr.DrawImage(picGraph.Image, -m_Dx, 0)

    ' Erase the right edge and draw guide lines.
    gr.ScaleTransform(1, -101 / picGraph.Height)
    gr.TranslateTransform(0, -101)
    For i As Integer = 20 To 80 Step 20
        gr.DrawLine(Pens.Red, picGraph.Width - m_Dx, i, _
            picGraph.Width, i)
    Next i

    ' Plot the new value.
    Dim new_value As Integer = NewValue()
    gr.DrawLine(Pens.Black, _
        picGraph.Width - 1 - m_Dx, m_OldValue, _
        picGraph.Width - 1, new_value)
    m_OldValue = new_value

    ' Display the results.
    picGraph.Image = bm
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated