Delphi7中运用chart组件问题

来源:百度知道 编辑:UC知道 时间:2024/06/06 00:19:08
如何查询指定txt文档中两种类型的数据,
并在chart组件中生成柱状图
例如:查询含有内容:
时间 (时分秒)、金钱(120.25)、年龄(30)
的 Adimin.txt, 取该文本文档中的 时间 和 金钱,
时间是X轴,金钱是Y轴, 显示曲线图或柱状图。

代码如下:
begin
a:=0;
b:=1;
if fileexists('E:\A1.txt') then
begin
mylist:=tstringlist.Create;
mylist.LoadFromFile('E:\A1.txt');
end;
i:=mylist.Count;
end;
以上是读取指定TXT文档。
Chart组件的代码:
var
z:integer;
begin
if a<i then
begin
x:=strtoint(mylist.Strings[a]);
a:=a+3;
end
else
a:=0;
Series1.Clear;
if b<i then
begin
y:=strtoint(mylist.Strings[b]);
b:=b+3;
end
else
b:=1;
Series1.Clear;
begin
for z:=0 to i div 3-1 do
Series1.Add(x);
Series1.Add(y);
//Series1.AddXY(x,y);
end;
应该是这样。