Note that there are some explanatory texts on larger screens.

plurals
  1. POMidnight-crossing , axis bounds and data storage order in TeeChart
    primarykey
    data
    text
    <p>I have an application that logs data and displays it continuously in a TeeChart using a fastLine series with time as the x-axis using...</p> <pre><code>Chart1.Axes.Bottom.DateTimeFormat:='hh:mm:ss'; </code></pre> <p>Data is added at approx one point per second but I wish to limit the number of points displayed to the last MaxPoints added (MaxPoints is an integer variable that can be updated by user input at any time). After there are MaxPoints displayed the data should scroll across the scrteen as it is added, as in a stripchart.</p> <p>I tried the following, where TheTime is Frac(Now)... </p> <pre><code>procedure TGraphForm.AddPoints(TheTime,TheData : real); begin Chart1.Series[0].AddXY(TheTime,TheData); while (Chart1.Series[0].Count &gt; MaxPoints) do Chart1.Series[0].Delete(0); end; </code></pre> <p>This works perfectly until midnight, where the display freezes. I understand that the problem is that the data is sorted as it is added so Series[0].Delete(0) deletes the data with the smallest x-value, (i.e. the newest piece of data added when midnight passes, not the oldest piece of data added to the series. </p> <p>I tried rescueing things by adding an external </p> <pre><code>var DeleteIndex : integer </code></pre> <p>and changing the procedure to...</p> <pre><code>procedure TGraphForm.AddPoints(TheTime,TheData : real); begin if TheTime &gt;= Chart1.Series[0].MaxXValue then DeleteIndex := 0 else inc(DeleteIndex); Chart1.Series[0].AddXY(TheTime,TheData); while (Chart1.Series[0].Count &gt; MaxPoints) do Chart1.Series[0].Delete(DeleteIndex); end; end; </code></pre> <p>but this is a horrible 'kludge' as then when I pass midnight a) the x-axis expands to show the full 24 hours and b) there is a line drawn between the newest point (near the far left of the graph) and the oldest remaining point of those added before midnight (near the far right of the graph). </p> <p>The alternate...</p> <pre><code>procedure TGraphForm.AddPoints(TheTime,TheData : real); begin if TheTime &lt; Chart1.Series[0].MaxXValue then Chart1.Series[0].Clear; Chart1.Series[0].AddXY(TheTime,TheData); while (Chart1.Series[0].Count &gt; MaxPoints) do Chart1.Series[0].Delete(0); end; </code></pre> <p>works, but the pre-midnight points are 'lost' at midnight as the graph is slowly repopulated after the clear, which is also less than desirable.</p> <p>The simplest 'solution' would be if the axis minimum and maximum could cross the midnight boundary, but it seems impossible to set the axis maximum to less than the minimum. </p> <p>I would be keen to hear of any alternate solutions anyone else might have come across for dealing with the 'midnight-crossing' problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload