Plotting a TChart with time as the X-axis

Mawg says reinstate Monica picture Mawg says reinstate Monica · Jan 25, 2011 · Viewed 13.5k times · Source

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

Answer

SimaWB picture SimaWB · Jan 25, 2011

You can use Add function instead of AddXY.

Add( 100, FormatDateTime('nn:ss',Now), clRed ); 
Add( 80, FormatDateTime('nn:ss',Now), clRed );