Hi,
I'm reading through a code example provided by Yeray » 03 May 2007 08:44. Here's a piece of that code.
for i := 0 to nSeries-1 do
begin
Chart1.AddSeries(TLineSeries);
Chart1.CustomAxes.Add;
Chart1.CustomVertAxis := Chart1.CustomAxes.Items;
Chart1.CustomAxes.Items.Axis.Color := Chart1.Color;
Chart1.CustomAxes.Items.Grid.Visible := False;
ComboBox2.Items.Add('Series' + inttostr(i + 1));
Chart1.FillSampleValues(20000);
Chart1.CustomAxes.Items.PositionUnits := muPixels;
if ((i+1) mod 2 = 0) then
Chart1.CustomAxes.Items.OtherSide := True;
end;
I'm confused by the array index attached to some of the Chart1 references in that code. I'm clearly missing something because that notation doesn't make any sense to me. The notation Chart1 suggests there is an array of several charts, however, I'm reasonably sure the example was meant to apply to a single instance of a single TChart component. I haven't been able to find anything in the documentation that suggests why this notation is valid. Can you explain what Yeray is up to there?
Thanks!
Brian
Confused by Chart1[i] notation
Re: Confused by Chart1[i] notation
Chart1 refers to the series for Chart1.
Re: Confused by Chart1[i] notation
Thank you for the reply. That's very helpful. I accept that answer although the syntax still doesn't make sense to me. I can't quite picture the underlying structure. It's probably obvious if you study the TeeChart source code - which I don't have. It's enough for my purposes right now to understand what the code does even if I don't know why that particular syntax works. Thanks again.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Confused by Chart1[i] notation
Hi bfalter,
Using Chart1 is the same as using Chart1.Series. I guess it was made for simplicity since most common objects to be in a chart are series but you can freely use the latter if you prefer.
Using Chart1 is the same as using Chart1.Series. I guess it was made for simplicity since most common objects to be in a chart are series but you can freely use the latter if you prefer.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Confused by Chart1[i] notation
Hi Narcis,
Thanks for the explanation. Everything makes sense now.
Best regards,
Brian
Thanks for the explanation. Everything makes sense now.
Best regards,
Brian