Real-time graph using Mschart
I am trying to plot a real time graph using Mschart control. I have an array Tot(). Each time Tot() gets new value the Mschart is plotted. My problem is instead of showing the graph, the Mschart control is just flickering. can anyone pl help me.
here is the code.
Private Sub Timer1_Timer()
ReDim Preserve Tot(cnt)
If (MouseOn = True) Then
Tot(cnt) = 10
Tot(cnt) = 0
.chartType = VtChChartType2dLine
.ShowLegend = True
.ChartData = Tot
cnt = cnt + 1
PS: MouseOn is just a boolean variable which is made true or false by some other even in my application.
A few questions about MSChart
I just started my first VB project and run into some similar problems as decribed in that thread. I am not that big of a programmer so I started with a simple task. My little program reads voltage from Keithley model 2000 DMM and plots them on the screen. I did the plotting in PictureBox with the following code inside a for loop (for now I am just reading 2000 data points and plting them)
and it works but I will have to take care of scaling the Y axis which I beleve is taken care of automatically by MSChart. So I tried the following
Y = (ReadingsArray(i%) - 53000#) / 1000#
Graph.PSet (i%, Y * (Graph.ScaleHeight / 2 ))
The above code takes care of the scaling allright but it shows the graph after all 2000 data points were collected.
So my question is: How do I update the graph after each and every single point?
I tried the code posted by mstraf (as is, not with my data points). It worked but the graph was flickering and I do not want that. Ideally I want the MSChart plot area to be of a fixed width (even when it is empty) and the data beeing plotted as they come. Your help is greatly appriciated.