Results 1 to 4 of 4

Thread: Chart Y axis autoscale quits working if I remove points from the series

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    21

    Chart Y axis autoscale quits working if I remove points from the series

    I am using Vb.Net - Visual Studio 2015

    I have a chart to which I am adding points at regular intervals as I sample a real world measurement (like an oscilloscope). The x axis is time and the Y axis is the value. The data that is graphed is selected by the user from any one of a hundred different data streams so I want the Y axis to automatically scale (which it is doing by default).

    However, after a period of time, the data series has enough points that the chart starts to bog down and affect the responsiveness of the GUI. (The user may add up to 10 series per chart and there are four charts.) I want to limit the number of points in the series to a value that it can handle without responsiveness issues. So, once the number of points in the series reaches the maximum that I want to allow, I remove the oldest point from the collection each time I add a new one to the series using the following lines:

    Series.Points.AddXY(seconds,value)
    Series.Points.RemoveAt(0)

    This works to remove the oldest point and my series stays fixed at the desired number of points.

    The issue is, once I begin removing points from the series like this, the Y axis autoscaling quits working.

    Any ideas why this happens? Or a way around it?

    Thanks in advance.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    21

    Re: Chart Y axis autoscale quits working if I remove points from the series

    I found a fix. Each time I add a new point, I use the following line:
    ChartArea.RecalculateAxesScale()
    It does what I want but I wonder if this is an inefficient way around it.

  3. #3
    Hyperactive Member
    Join Date
    Jun 2018
    Posts
    434

    Re: Chart Y axis autoscale quits working if I remove points from the series

    Tiger,

    I normally just recreate the entire series to redraw it with new data.

    For example keep a list of the data points, remove one as required, then remake the series from the updated data list by clearing the chart series and remaking it.

    Don't try to update the existing chart series as this is problematic.

    However, I think in your case you might try chart1.refresh ?

    If you are really up against a speed issue ie you have like over 10000 points and are drawing a line graph you can use the fastline graph it is much faster.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    21

    Re: Chart Y axis autoscale quits working if I remove points from the series

    Tommy,

    This seems like it would be inefficient to clear the series and then add all of the points back in instead of just removing one point. But. I have no idea what actually happens when I call the RecalculateAxesScale method so it entirely possible that it is less efficient than clearing and re-entering the points. If there is an easy explanation as to why this is better I would be happy to hear it.

    Either way, I will give it a try. I may also try the Refresh method. And, thanks for suggesting the fastline graph. I did not even know it existed.

    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width