Page 1 of 1

Many charts on a form

Posted: Fri Dec 08, 2006 10:14 pm
by 9231397
I have a form with 32 Teecharts, and each chart has 5 tlineseries. In order to make accessing chart properties easier in code I've created an array of charts in form create, and assigned these to the charts I place on form at design time. See code below. My question is, is this good practice, and do I need to free the charts aray in form close event.

type
Tmyfrm = class(TForm)
.
.

private
mycharts:array[1..32] of tchart;


procedure Tmyfrm.create(sender:TObject);
var
i:nteger;
begin
for i:=1 to chartcount do
charts:=Tchart.create(self);
charts[1]:=chart1;
charts[2]:=chart2
etc
end;



Can the access charts by array element with things like

for i:=1 to nocharts do
begin
charts.Legend.visible:=true;//false;
charts.MarginRight:=200;
charts.Marginleft:=0;
end;


My question is, is this a good way to do this,
and do I need to have the following in the forms onclose event.

for i:=1 to nocharts do
begin
charts.Free;
end;

Posted: Sat Dec 09, 2006 2:56 pm
by 9242408
I use something similiar myself and it works great. You do not have to free them, at least I have'nt and all is well.

I do something like this for dealing with my charts:

Code: Select all

private
    { Private declarations }
    mychart: Array of TChart;


     MyChart[idx]:=TChart.Create(Self);
     MyChart[idx].Parent := JvScrollBox1;
     MyChart[idx].Height := 246;
     MyChart[idx].Width := 1000;
     MyChart[idx].Left := 0;
     MyChart[idx].Top := lastchart;
     MyChart[idx].View3D := False;
     MyChart[idx].BackColor := ClWhite;
     MyChart[idx].Color := ClWhite;

That gives you an idea anyways.


HTH


Tom