Gladly, I will try to post some snippets and explain them the best I can. I have this working perfectly for my application, hope it works for yours. I used a standard fastline control not the AHMI control only because I wanted to trend the same register of 5 different controllers.
The first thing I did was set the size of the trend window. This was to prevent compression of the lines after running a long time. The value of 500 was an arbitrary number as I found this to do well for my application
'********************************************************************************************************************************
'The following code sets the size of the chart so that the data on the X axis does not get compressed
'The Chart accumulator holds the last position so that it can prevent over scrolling to the right
' "TIME" is current PC time
'********************************************************************************************************************************
Dim Chart1Accumulator, Chart2Accumulator, Chart3Accumulator, Chart4Accumulator, Time As String
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Time = DateAndTime.Now.ToString("h:mm:ss")
Chart1.ChartAreas(0).AxisX.Minimum = (Chart1.ChartAreas(0).AxisX.Maximum - 500)
Chart2.ChartAreas(0).AxisX.Minimum = (Chart2.ChartAreas(0).AxisX.Maximum - 500)
Chart3.ChartAreas(0).AxisX.Minimum = (Chart3.ChartAreas(0).AxisX.Maximum - 500)
Chart4.ChartAreas(0).AxisX.Minimum = (Chart4.ChartAreas(0).AxisX.Maximum - 500)
As for scrolling, I simply added a button with this code to decrement the chart maximum value by 100
'********************************************************************************************************************************
'The following code allows for scrolling left of chart 2
'********************************************************************************************************************************
Private Sub ScrollLeft2_Click(sender As Object, e As EventArgs) Handles ScrollLeft2.Click
If PAUSE2.Visible = False Then
Chart2.ChartAreas(0).AxisX.Minimum = Chart2.ChartAreas(0).AxisX.Minimum - 100
Chart2.ChartAreas(0).AxisX.Maximum = Chart2.ChartAreas(0).AxisX.Maximum - 100
End If
End Sub
Scroll the other way
'********************************************************************************************************************************
'The following code allows for scrolling right of chart 2
'********************************************************************************************************************************
Private Sub ScrollRight2_Click(sender As Object, e As EventArgs) Handles ScrollRight2.Click
If PAUSE2.Visible = False Then
If Chart2.ChartAreas(0).AxisX.Maximum <= Chart2Accumulator Then
Chart2.ChartAreas(0).AxisX.Minimum = Chart2.ChartAreas(0).AxisX.Minimum + 100
Chart2.ChartAreas(0).AxisX.Maximum = Chart2.ChartAreas(0).AxisX.Maximum + 100
ElseIf Chart2.ChartAreas(0).AxisX.Maximum > Chart2Accumulator Then
MsgBox("END OF CHART REACHED")
End If
End If
End Sub
Actually plotting the data was accomplished by always plotting the X axis as PC time but the trick was to set the y value to "Double.NAN" when you didn't want it to graph. This allowed you to start and stop each graph and always have each series at the same X value of PC time.
Chart1Accumulator = Chart1.ChartAreas(0).AxisX.Maximum
If CheckBox1.Checked = True Then
CHART1GEN1 = BasicLabel1.Text
Else
CHART1GEN1 = Double.NaN
End If Chart1.Series("Gen 1").Points.AddXY(Time, CHART1GEN1)
This is of course a condensed version, so let me know if I can be of further help. Hope this works for you.