Page 1 of 1

Runtime TFastlineSeries creation

Posted: Thu Nov 01, 2007 10:42 am
by 9245460
Hello!

I have some problems with generating Series(TFastlineSeries) with for loop. I would like to create 10 Series (TFastLineSeries) at runtime or on form creation... But then I have problems with displaying all 10 series on Chart.


Now I have code like that:

procedure TForm2.Button1Click(Sender: TObject);
var X,Y:single;
i, j:integer;
Series: TFastLineSeries;
begin

for j:=0 to 9 do
begin
Series:= TFastLineSeries.Create(Chart1);
Series.Name := 'Series'+IntToStr(j);
Series.XValues.Order:=loNone;
Series.YValues.Order:=loNone;

// calc points for circles
for i := 0 to 360 - 1 do
begin
X := (10+j*10) * cos ( i*PI/180 );
Y := (10+j*10) * sin ( i*PI/180 );
Series.AddXY(X,Y,'',clRed);
end;

Chart1.SeriesList.Add(Series);
Chart1.SeriesList.AllActive:=true;
end;

I expect that I would see 10 circles with different radius, but nothing happend to Chart.... I assume that there should be some code to display or refresh these 10 series on chart.

Does anybody know how can I display those 10 series.

Thank you in advance.

BR

Posted: Thu Nov 01, 2007 2:30 pm
by 10046032
Hello,

Try this:

Chart1.AddSeries(Series);

Regards

Posted: Thu Nov 01, 2007 7:52 pm
by 9047589
10046032 wrote: Chart1.AddSeries(Series);
either

Code: Select all

Series.ParentChart:=Chart1
but also you need

Code: Select all

Series:= TFastLineSeries.Create(Self); 
as Form is an owner of the component Series

Posted: Fri Nov 02, 2007 9:25 am
by narcis
Hi BR,

Have other users suggestions helped?

Also notice that if you are planning to draw circles you may be interested in using bubble series where you can specify each bubble center (X,Y) and radius. You could set bubble series brush to bsClear if you only want the pen being drawn, for example:

Code: Select all

  Series1.Brush.Style:=bsClear;

Working!

Posted: Mon Nov 05, 2007 10:12 pm
by 9245460
Thank you guys you realy helped me a lot.

There are so many properties for TChart that I lost myself within it.

About drawing the circles... that was only an example to show you what I mean (easier to describe problem).

Thank you again.

BR
Aljosa

How to assign Series to axis

Posted: Wed Nov 07, 2007 6:34 pm
by 9245460
With your answer you helped me a lot. But I have one more question to ask you.

I have three axes. Left, right and bottom... At first when I create those TFastLineSeries and add it to TChart they are assigned to LeftAxis and Bottom Axis...

How can I switch between combinations of LeftAxis&BottomAxis or RightAxis&BottomAxis?

So I want to assign series sometimes to left axis and sometimes to right axis (bottom is always present)... How can I do that?

Thanks in advance!

BR
Aljosa

Posted: Thu Nov 08, 2007 10:30 am
by narcis
Hi Aljosa,

You'll find information on that at Tutorial 6 - Working with Series, specially at the Choose Axes for a Series section. You'll find the tutorials at TeeChart's program group.

Hope this helps!