Many charts on a form

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
seanmurphy
Newbie
Newbie
Posts: 48
Joined: Fri Mar 12, 2004 5:00 am

Many charts on a form

Post by seanmurphy » Fri Dec 08, 2006 10:14 pm

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;

tbonejo
Newbie
Newbie
Posts: 73
Joined: Wed Sep 06, 2006 12:00 am
Contact:

Post by tbonejo » Sat Dec 09, 2006 2:56 pm

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
Tom

Post Reply