Click here to Skip to main content
14,329,823 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a chart in my application, in which, the points are like time and a value pair.
Time On X-axis, and value on y-axis. and for each second or 100 mille seconds a new point will be added to the chart.

Here the problem is when a new point added, the graph points gets closer, but i want to move or scroll the older points to the left of the chart.

I am adding my code snippets here..

Private Sub Graph_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        XVal = DateTime.Now
        YVal = rnd.Next(50, 100)
        With Chart1.Series(0)
            .Name = "Sample"
            .ChartType = SeriesChartType.Spline
            .Color = Color.Black
            .IsValueShownAsLabel = False
            .IsXValueIndexed = False
            .Points.AddXY(XVal, YVal)
        End With
        With Chart1.ChartAreas(0)
            .AxisX.IntervalType = DateTimeIntervalType.Minutes
            .AxisX.Interval = 1
            .AxisY.Interval = 10
            .AxisX.LabelStyle.Angle = -90
            .AxisX.Title = "TimeStamp"
            .AxisY.Title = "Units"
            .CursorX.IsUserEnabled = True
            .CursorX.IsUserSelectionEnabled = True
            .CursorX.IntervalType = DateTimeIntervalType.Minutes
            .CursorX.Interval = 0.5D

            .AxisX.ScaleView.SmallScrollSizeType = DateTimeIntervalType.Minutes
            .AxisX.ScaleView.SmallScrollSize = 0.5D
            .AxisX.ScaleView.Zoomable = True
            .AxisX.LabelStyle.Format = "hh:mm:ss"
            .AxisX.ScrollBar.Enabled = True
                    End With
    End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.tick
        Chart1.Series(0).Points.AddXY(DateTime.Now, rnd.Next(50, 100)
    End Sub

I need help on this ASAP, any help will be greatful
Updated 29-Nov-18 4:32am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I realise it has been 5 years since OP posted, but in case someone else stumbles upon this post with the same problem.

This is an example of what I used in one of my projects:

If Chart1.Series("LoadCell").Points.Count >= 100 Then
End If

It Auto scales the y axis as well as limiting the x axis to 100 by removing the first entry when the entries exeed 100.

Hope it helps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100