Search code examples
delphiteechart

Plotting a TChart with time as the X-axis


I have a series of 3,600 values, one every second for an hour. I want to chart them as a single series, using TChart in Delphi 7.

The values should be plotted on the Y-axis. What should I pass to AddXY() as the X-axis value? The count of points?

I want to label the X-axis as MM:SS, how do I do that? What do I need beyond this? ...

   Chart1.Series[0].XValues.DateTime := True;
   Chart1.BottomAxis.DateTimeFormat := 'nn:ss';

I have been stuck for a while with this one. Can anyone post some sample code? Thanks


Solution

  • If I am not wrong, this is what you want

    Series1.AddXY(<Pass the data value>, <Pass Your value>, '', clRed);
    Series1.AddXY(now,                     1, '', clRed); 
    Series1.AddXY(now + ( 1 /(24*60*60)),  2, '', clRed); //After 1 seconds 
    Series1.AddXY(now + ( 2 /(24*60*60)),  3, '', clRed);  //After 2 seconds