[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 277

# help me to make a dynamic graph in picture box in a particular trend

help me to make a dynamic graph in picture box in a particular trend
i.e the graph should be running in a picture box like a sine wave
graph should start from left side of the picture box
0
rkpune
• 6
• 4
1 Solution

Commented:
Do you mean a constantly moving graph similar to the Perfomance CPU history in the Windows Task Mangler?
0

Author Commented:
Yes, I want a constantly moving graph in picture box. Yes it should be like CPU History in Win Task manager. But I want it to be moving from left to right.
Thanks in anticipation
0

Commented:
well, u have dynamic y- values -
what type of graph u need , curve or line ?
0

Author Commented:
I want both types of graphs.
0

Author Commented:
there is no answer till now
pls forward it asap
thanks
0

Commented:
0

Commented:
Or to move from left to right, use the above and change the timer event handler like so:

Private Sub Timer1_Timer()
Dim i As Integer
Call BitBlt(hDCh, _
0, _
0, _
pWidth - 1, _
pHeight, _
hDCh, _
-1, _
0, _
SRCCOPY)

If counter Mod pGrid = 0 Then
Call MoveToEx(hDCh, 1, 0, 0)
Call LineTo(hDCh, 1, pHeight)
End If

i = Sin(0.1 * counter) * _
(pHeightHalf - 1) + _
pHeightHalf

Call SelectObject(hDCh, hPenC)
Call MoveToEx(hDCh, 2, oldY, 0)
Call LineTo(hDCh, 1, i)
Call SelectObject(hDCh, hPenB)
Call BitBlt(Picture1.hdc, _
0, _
0, _
pWidth, _
pHeight, _
hDCh, _
0, _
0, _
SRCCOPY)
counter = counter + 1
oldY = i
End Sub
0

Author Commented:
how to increase the width of the distance betbeen the graphs?
that is i want to make an irreregular graph
a graph like an ecg graph
0

Commented:
Just change the

i = Sin(0.1 * counter) * _
(pHeightHalf - 1) + _
pHeightHalf

to whatever you want it to be.

If you want to do an ecg looking thing then you'll need an array of values to set i to. Every timer event, set the value of i to the next value in your array. Every time you get to the end of the values, set i back to the first one.

I have no idea what should be in the array, I'm not a computer programmer, not a doctor.
0

Commented:
>>I'm not a computer programmer, not a doctor

ha ha - did I really write that. Some people might say that its true. I should have said

"I'm a computer programmer, not a doctor."
0

Commented:
Hello

Do you require anything else?
0

## Featured Post

• 6
• 4
Tackle projects and never again get stuck behind a technical roadblock.