Page 1 of 1

SeriesGroups not reacting at Runtime

Posted: Mon Nov 02, 2009 7:36 pm
by 10547084
I drop a DBchart on a form.
I then Add 20 series.
I add two Seriesgroups, and assign the series 10 to each seriesgroup.
Each series points to its respective datasource.

I then tick one of the two seriesgroups, and the chart then displays correctly at runtime.

Now I try to change the active seriesgroup at runtime, without any effect:
With DBChartBlup do
begin
SeriesGroups.Items[0].Active:=TSeriesGroupActive(1);
SeriesGroups.Items[1].Active:=TSeriesGroupActive(0);
RefreshData;
end;

No matter what I do:
SeriesGroups.Items[0].Active:=TSeriesGroupActive(0);
SeriesGroups.Items[1].Active:=TSeriesGroupActive(0);
or
SeriesGroups.Items[0].Active:=TSeriesGroupActive(1);
SeriesGroups.Items[1].Active:=TSeriesGroupActive(1);

seriesgroups remain at what they where set to in the IDE.

So, how do I achieve this at runtime, without having to set up all the series, and seriesgroups etc at runtime.

Regards

Adrian

Re: SeriesGroups not reacting at Runtime

Posted: Tue Nov 03, 2009 9:25 am
by yeray
Hi Adrian,

I've taken the code from the demo at All features\Welcome !\Miscellaneous\Series\Series Goups to test it and everything seems to work as expected. What TeeChart exact version are you using?

Code: Select all

uses series;

var  Group1, Group2 : TSeriesGroup;

procedure TForm1.FormCreate(Sender: TObject);
var t : Integer;
    Line : TChartSeries;
begin
 for t:=0 to 9 do
  begin
    Line:=Chart1.AddSeries(TLineSeries);
    Line.Title:='Line '+IntToStr(t);
    Line.FillSampleValues;
  end;

  // Create two "Series Groups", and add some series to each group...
  Group1:=Chart1.SeriesList.AddGroup('First group');
  Group1.Add( Chart1[0] );
  Group1.Add( Chart1[2] );
  Group1.Add( Chart1[4] );
  Group1.Add( Chart1[6] );
  Group1.Add( Chart1[8] );

  Group2:=Chart1.SeriesList.AddGroup('Second group');
  Group2.Add( Chart1[1] );
  Group2.Add( Chart1[3] );
  Group2.Add( Chart1[5] );
  Group2.Add( Chart1[7] );
  Group2.Add( Chart1[9] );

  // Show all series in first group
  Chart1.SeriesList.Groups[0].Show;

  // Hide all series in second group
  Chart1.SeriesList.Groups[1].Hide;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  With Chart1.SeriesGroups do
  begin
    if Items[0].Active = gaYes then
    begin
      Items[0].Active:=gaNo;
      Items[1].Active:=gaYes;
    end
    else
    begin
      Items[0].Active:=gaYes;
      Items[1].Active:=gaNo;
    end;
  end;
end;

Re: SeriesGroups not reacting at Runtime

Posted: Wed Nov 04, 2009 8:19 pm
by 10547084
V8.02.10861

Also note, that I don't want to build the series groups at runtime, but use them as set up in the IDE.
Regards

Adrian

Re: SeriesGroups not reacting at Runtime

Posted: Thu Nov 05, 2009 11:08 am
by yeray
Hi Adrian,

I've found that at design time adding a series to a group is listed fine but the group doesn't seem to really contain the series:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  Showmessage(inttostr(Chart1.SeriesGroups.Items[0].Series.Count));
end;
On the other hand, having a group created at design time, you can add series at runtime:

Code: Select all

procedure TForm1.Button2Click(Sender: TObject);
  with Chart1.SeriesGroups.Items[0] do //group created at design time
  begin
    Add( Chart1[0] ); 
    Add( Chart1[2] );
  end;
  Showmessage(inttostr(Chart1.SeriesGroups.Items[0].Series.Count));
end;
I've added this to the wish list to be fixed in future releases (TV52014535). In the meanwhile I recommend you to add the series to the groups at runtime if possible.