yunqian09 发表于 2010-2-14 23:11:24

初学delphi 求高手解释下这段代码! Tchart 和 Timer的 谢谢

Procedure TMainForm.TimerTimer(Sender: TObject);
Begin
Chart1.Series.AddXY(I, TemperData, TimeToStr(Time));
If I < 60 Then
    XStr := TimeToStr(Time)
Else
Begin
    XStr := TimeToStr(Time);
    Inc(Y);
    Chart1.BottomAxis.SetMinMax(Y, Y + 59);
End;
Inc(I);
End;

=====================================
转自
我也贴个我第一次做的DS18B20温度计,含DELPHI上位机曲线图和PCBhttp://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=3877366&bbs_page_no=1&search
这是SkyGz   发布的程序的一段求高手 解释下看不懂谢谢./emotion/em048.gif

yunqian09 发表于 2010-2-14 23:59:00

查到AddXY的定义是这样子的。应该有4个参数   ,但是上面的程序只有3个参数,?难道那个可以省略吗??

{ Adds a new point into the Series. }
Function TChartSeries.AddXY( Const AXValue,AYValue:Double;
                           Const ALabel:String; AColor:TColor):Integer;
var t : Integer;
Begin
FX.TempValue:=AXValue;
FY.TempValue:=AYValue;

if (not Assigned(FOnBeforeAdd)) or FOnBeforeAdd(Self) then
Begin
    result:=FX.AddChartValue; // (FX.TempValue);   // 7.0
    FY.InsertChartValue(result,FY.TempValue);

    for t:=2 to ValuesList.Count-1 do
      With ValuesList do InsertChartValue(result,TempValue);

    if Assigned(FColors) then
       FColors.Insert(result,{$IFDEF CLR}TObject{$ELSE}Pointer{$ENDIF}(AColor))
    else
    if AColor<>clTeeColor then
    begin
      GrowColors;
      FColors.Insert(result,{$IFDEF CLR}TObject{$ELSE}Pointer{$ENDIF}(AColor));
    end;

    if (ALabel<>'') or (FLabels.Count>0) then { speed opt. 5.02 }
       Labels.InsertLabel(result,ALabel);

    if IUpdating=0 then { 5.02 }
       NotifyNewValue(Self,result);
end
else result:=-1;
end;

haeha 发表于 2010-2-15 00:16:38

TChartSeries.AddXY
TChartSeries
function AddXY(Const AXValue, AYValue: Double; Const ALabel: String; AColor: TColor): Integer; virtual;

Unit
TeEngine

Description
This function inserts a new point in the Series.
The new point has X and Y values.

The ALabel parameter is optional (can be empty '').
The AColor parameter is optional (can be clTeeColor).
The function returns the new point position in the Values list.

Series1.AddXY( 123, 456, 'Hello', clGreen );

yunqian09 发表于 2010-2-15 10:27:28

回复【2楼】haeha
-----------------------------------------------------------------------

谢谢


还有个问题   这段代码 放在   Procedure TMainForm.TimerTimer(Sender: TObject);

这个函数里面是什么意思啊??谢谢

yunqian09 发表于 2010-2-15 20:31:01

http://cache.amobbs.com/bbs_upload782111/files_26/ourdev_533976.jpg
(原文件名:11.jpg)

http://cache.amobbs.com/bbs_upload782111/files_26/ourdev_533977.jpg
(原文件名:22.jpg)
知道了
          函数Procedure TMainForm.TimerTimer(Sender: TObject);是Timer定时时间 1s到的时候的执行函数

kingsabbit 发表于 2010-2-18 14:48:33

Procedure TMainForm.TimerTimer(Sender: TObject);
这个是定时器的中断函数

sunjie718 发表于 2010-3-17 21:43:44

delephi怎么调用VB谢谢程序
对VB的文本框text   combo   command
进行调用,谢谢各位啊
页: [1]
查看完整版本: 初学delphi 求高手解释下这段代码! Tchart 和 Timer的 谢谢