Recent

Author Topic: Show Last X samples in Graph  (Read 1323 times)

Bas

  • New Member
  • *
  • Posts: 16
Show Last X samples in Graph
« on: June 19, 2020, 09:55:48 am »
In a graph i show realtime data which is coming in at 100Hz so the graph fills up very quickly. Is it possible to show only the last 1000 or 10000 samples with the graph shifting automaticly  ?

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Show Last X samples in Graph
« Reply #1 on: June 19, 2020, 10:20:56 am »
What should happen with the older values? Should they be deleted so that the series contains never more then, say, 1000 points? Or should they still be stored but the visible window should be decreases so that only the last 1000 points are visible although there are more points in the series? In the latter case, should it be possible to scroll back to previous data points, or should there be a need to see all points?
« Last Edit: June 19, 2020, 10:46:06 am by wp »

Bas

  • New Member
  • *
  • Posts: 16
Re: Show Last X samples in Graph
« Reply #2 on: June 19, 2020, 10:29:11 am »
Older points can just be disregarded/deleted

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Show Last X samples in Graph
« Reply #3 on: June 19, 2020, 10:45:23 am »
Play with the attached demo.

Bas

  • New Member
  • *
  • Posts: 16
Re: Show Last X samples in Graph
« Reply #4 on: June 19, 2020, 12:56:29 pm »
That works fine but due to the moving grid in the backgroud it looks like crap  :D . Is there a way to switch off the x-axis on the grid in the background ?

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Show Last X samples in Graph
« Reply #5 on: June 19, 2020, 01:30:07 pm »
Code: Pascal  [Select][+][-]
  1. Chart1.BottomAxis.grid.Visible := false;    // Hide the x axis grid
  2. Chart1.BottomAxis.Marks.visible := false;   // Hide the x axis labels and ticks

You may also want to keep the x axis at a constant scaling factor to avoid the expansion while the first data points are added. Put this code into the routine which receives the data, in my example in the OnTimer event handler:

Code: Pascal  [Select][+][-]
  1.   Chart1.BottomAxis.Range.Max := t;
  2.   Chart1.BottomAxis.Range.Min := t - MAX_POINTS * Timer1.Interval/1000;
  3.   Chart1.BottomAxis.Range.UseMax := true;
  4.   Chart1.BottomAxis.Range.UseMin := true;
  5.  

Bas

  • New Member
  • *
  • Posts: 16
Re: Show Last X samples in Graph
« Reply #6 on: June 22, 2020, 06:14:54 am »
Thx, works all perfect now

 

TinyPortal © 2005-2018