Plotting a TChart with time as the X-axis

微笑、不失礼 提交于 2019-12-10 21:07:21

问题


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


回答1:


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 



回答2:


You can use Add function instead of AddXY.

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


来源:https://stackoverflow.com/questions/4791053/plotting-a-tchart-with-time-as-the-x-axis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!