Chart Control - real time data - scrolling


  • Hi

    Having problems with chart control with real time data adding two points and getting it to automatically scroll as data is added

    Tried all the samples and spent hours googling but nothing I try works - closest I got was with sample in but this didn't work for two points in line chart

    So I have following code currently

    All works and graph shows, but as more data is added it is slowly compressed and cannot be legible - so need to scroll automatically as data is added so always seeing new values but can move scroll bar back to see old

    Please advise


     Dim graph_upload As New DataVisualization.Charting.Series
        Dim graph_download As New DataVisualization.Charting.Series
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    ' configure graph
            graph_upload.Name = "Upload"
            graph_upload.ChartType = DataVisualization.Charting.SeriesChartType.Line
            graph_upload.Color = Color.Red
            graph_upload.BorderWidth = 2
            graph_upload.ToolTip = "#VAL{0.00}Kb"
            graph_download.Name = "Download"
            graph_download.ChartType = DataVisualization.Charting.SeriesChartType.Line
            graph_download.Color = Color.Blue
            graph_download.BorderWidth = 2
            graph_download.ToolTip = "#VAL{0.00}Kb"
            Chart1.ChartAreas("ChartArea1").AxisX.Title = "Time (seconds)"
            Chart1.ChartAreas("ChartArea1").AxisY.Title = "Kb/sec"
    End Sub
    And then I am adding points in a timer - the up/down values contain current upload/download speeds
    graph_upload.Points.Add(Up / 1024)
            graph_download.Points.Add(Down / 1024)

    Darren Rose

    Friday, March 31, 2017 10:43 PM

All replies

  • Please check the below post, I think it answers your question:

    Real time data to chart control

    Fouad Roumieh

    Saturday, April 1, 2017 12:16 PM
  • Thanks - think I have now got it only showing latest points but can't seem to get scroll bar to work - as when it appears the data then keeps going but scrollbar stays left rather than right

    Darren Rose

    Saturday, April 1, 2017 12:51 PM
  • Each time you adding points try to reset the view and scroll to the max in xAxis, something like:

    Chart1.ChartAreas(0).AxisX.ScaleView.Zoom(0, xmax)

    Chart1.ChartAreas(0).AxisX.ScaleView.Position = xmax

    Fouad Roumieh

    • Edited by Fouad Roumieh Saturday, April 1, 2017 2:27 PM edited typo from C#
    Saturday, April 1, 2017 2:27 PM
  • Thanks, tried that but then it seems to scroll too quickly and I can't see data as it is further to the left off the current view

    Never realised working with charts could be such a pain

    Also tried getting it to recalculate y axis so scale correct to what is shown but that doesn't work unless I remove points as I add them - and then bottom axis doesn't increment like it does without

    Think I will give up on this for now

    Thanks for helping

    Darren Rose

    Saturday, April 1, 2017 3:31 PM