Author Topic: ChartbySampling - stops updating after a while  (Read 1674 times)

paulm

  • Newbie
  • *
  • Posts: 10
    • View Profile
ChartbySampling - stops updating after a while
« on: February 20, 2017, 09:48:14 AM »
I am successfully displaying data in the  chartbysampling object however after a while the chart stops updating and the Time on the X axis stops. Is there any way the chart can keep updating with the latest data values.

Thanks

Paul



Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: ChartbySampling - stops updating after a while
« Reply #1 on: February 20, 2017, 10:07:57 AM »
Does the chart stop recording or does it start discarding the oldest points? There is a property named MaximumActivePoints that limits the amount of data points on the chart. When it reaches that number of points, it discards the oldest. If your point values are not changing, it may appear the chart is no longer sampling.

paulm

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: ChartbySampling - stops updating after a while
« Reply #2 on: February 20, 2017, 10:54:09 AM »
Hi Archie,

Thanks for your reply

The chart seems to stop recording as the lines on the chart eventually disappear and the time on the X axis stops. see attachment
I know the value is good and comms are OK  as i am displaying this on a meter as well

It seems as though the Chart stops displaying new values when it has reached maximum data points.

Regards

Paul

paulm

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: ChartbySampling - stops updating after a while
« Reply #3 on: February 20, 2017, 11:10:09 AM »
Hi Archie

I have set the series  XvalueType to Auto and this works however I need to display time on the X axis so it needs to work with Time selected

Regards

Paul

paulm

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: ChartbySampling - stops updating after a while
« Reply #4 on: February 21, 2017, 11:10:38 AM »
Hi Archie

Did you find any issue with the X axis not continue when set to time but OK in Auto

Regards

Paul

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: ChartbySampling - stops updating after a while
« Reply #5 on: February 22, 2017, 07:14:39 PM »
- In Solution Explorer, expand down the AdvancedHMIControls project
- Expand down the Controls folder
- Right click ChartBySampling.vb and select View Code
- Go to line 314 and modify the code like this:
Code: [Select]
        If MyBase.Series(index).Points.Count > m_MaximumActivePoints Then
            MyBase.Series(index).Points.RemoveAt(0)

            '* When X-Axis set to Date or Time, it does not auto scale, so force it
            If MyBase.Series(index).XValueType = DataVisualization.Charting.ChartValueType.Time Or
                MyBase.Series(index).XValueType = DataVisualization.Charting.ChartValueType.Date Or
                 MyBase.Series(index).XValueType = DataVisualization.Charting.ChartValueType.DateTime Then

                MyBase.ChartAreas(0).Axes(0).Maximum = MyBase.Series(index).Points(MyBase.Series(index).Points.Count - 1).XValue
                MyBase.ChartAreas(0).Axes(0).Minimum = MyBase.Series(index).Points(0).XValue
            End If
            ' MyBase.Series(index).Points.Remove(x)
        End If

paulm

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: ChartbySampling - stops updating after a while
« Reply #6 on: February 24, 2017, 02:58:42 AM »
Thanks Archie - Looks like its working now