Page 1 of 1

Changing TBarSeries properties at runtime

Posted: Mon Aug 22, 2005 9:41 am
by 9236090
Hi !

I am working in the field of multivariate statistics. This means I like to handle a large amount of variables. Creating series for these variables at designtime is not an option, I like to create them at runtime. I am using this code in Delphi-7 and TeeChart VCL 7.04:

for i:= 1 to 31 do Chart.AddSeries(TBarSeries.Create(Self));

Adding data values for the bar charts and some basic formatting is not a problem using:

for i:= 1 to 31 do
for j:= 1 to 6 do
begin
Chart.Series.AddXY(j,SomeYvalue,'',MyColorList);
Chart.Series.Marks.Visible:=False;
Chart.Series.Color:=MyColorList;
Chart.Series.Title:=’TextInLegend’;
end;

No problem so far, but now I want to change the BarWidthPercent for the bar charts from the default 70% to 95%. And maybe I want to set other specific TBarSeries properties, that can not be reached by Chart.Series. Is there a way to accomplish this ?

Thanks for your attention and kind regards from Gerben

Posted: Mon Aug 22, 2005 10:04 am
by narcis
Hi Gerben,

Yes, this is possible but to reach those properties you will need to type cast your series as Chart.Series[0] is of TChartSeries type:

Code: Select all

(Chart1.Series[i] as TBarSeries).BarWidthPercent:=95;
or

Code: Select all

(Chart1[i] as TBarSeries).BarWidthPercent:=95;