procedure TForm1.FormCreate(Sender: TObject);
var
i,j : Integer;
begin
randomize;
for i := 1 to StringGrid1.RowCount do
for j := 1 to StringGrid1.ColCount do begin
StringGrid1.Cells[j,i] := IntToStr(round(random(100) ));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
LineSeries: array of TLineSeries;
i, j, index: Integer;
ChartCount: Integer;
begin
setLength(LineSeries, StringGrid1.ColCount);
for i := 0 to StringGrid1.ColCount - 1 do
begin
LineSeries[i] := TLineSeries.Create(self);
LineSeries[i].ParentChart := Chart1;
Chart1.AddSeries(LineSeries[i]);
//LineSeries[i].Title := SeriesName[i];
LineSeries[i].LinePen.Width := 2;
저도 TeeChart 때문에 고생한 경험이 있어 안타까운 맘에 제가
예전에 작성했던 내용을 수정해서 일부 올립니다.
사용방법은 대충 아래와 같습니다.
아마 이정도 예제면 TeeChart 를 다루는데 큰 어려움은 없을겁니다.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Db, DBTables, contnrs, TeeProcs, TeEngine, Chart,
Series, DBChart, OleServer, Excel97, Buttons, ComObj, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Panel1: TPanel;
Chart1: TChart;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
i,j : Integer;
begin
randomize;
for i := 1 to StringGrid1.RowCount do
for j := 1 to StringGrid1.ColCount do begin
StringGrid1.Cells[j,i] := IntToStr(round(random(100) ));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
LineSeries: array of TLineSeries;
i, j, index: Integer;
ChartCount: Integer;
begin
setLength(LineSeries, StringGrid1.ColCount);
for i := 0 to StringGrid1.ColCount - 1 do
begin
LineSeries[i] := TLineSeries.Create(self);
LineSeries[i].ParentChart := Chart1;
Chart1.AddSeries(LineSeries[i]);
//LineSeries[i].Title := SeriesName[i];
LineSeries[i].LinePen.Width := 2;
end;
for i := 1 to StringGrid1.ColCount do
begin
for j := 1 to StringGrid1.RowCount do
begin
LineSeries[i-1].Add(strToFloat(StringGrid1.Cells[i,j]), StringGrid1.Cells[i, 0],
clTeeColor);
end;
end;
end;
end.