Page 1 of 2

GetASeries Method

Posted: Tue Sep 19, 2006 9:02 am
by 9347181
Hi,
Can sombody explain the GetASeries method :?: I can't find any reference to it in the Users Guide.

Thanks!

Posted: Tue Sep 19, 2006 9:21 am
by narcis
Hi CCRyder,

You can find the reference at the help file:

The GetASeries function returns the FIRST Active Series in a Chart. If Chart has no Series, or none of the Series is Active, this function returns NIL.

Posted: Tue Sep 19, 2006 9:50 am
by 9347181
Thanks Narcis,
I was looking in the wrong place :oops:

Posted: Tue Sep 19, 2006 10:01 am
by 9347181
Hi Narcis,
How can I select a different series in a Gantt Chart. For instance I have a Gantt Chart with three Series and when I click on one of the bars in a different series that particular series should then be selected.

CCRyder

Posted: Tue Sep 19, 2006 10:09 am
by narcis
Hi CCRyder,

You can do something like this:

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var i, SeriesIndex: Integer;
begin
 SeriesIndex:=-1;
 for i:=0 to Chart1.SeriesCount-1 do
  if (Chart1[i].Clicked(X,Y)<>-1) then
  begin
    SeriesIndex:=i;
    break;
  end;

 if (SeriesIndex<>-1) then
  Chart1[SeriesIndex].Color := clLime;
end;

Posted: Tue Sep 19, 2006 10:59 am
by 9347181
Works perfect!

Thanks!

Posted: Tue Sep 19, 2006 4:31 pm
by 9347181
Hi Narcis,
Is there a way to find out how many bars are in a specific gantt series? What I am trying to do is create a graph containing more than one Gantt Series and when I add a new series (which can have the same date and time for some of the bars) I want to locate this series under the first set of bars without having to enter the Y positions manually.

Best regards,
CCRyder

Posted: Wed Sep 20, 2006 7:42 am
by narcis
Hi CCRyder,

You can see the number of values (bars) a gantt series has using:

Code: Select all

  Series1.Count
To get its values and copy them to another series you could do something like this:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Series1.FillSampleValues();

  for i:=0 to Series1.Count-1 do
  begin
    Series2.AddGantt(Series1.StartValues[i],Series1.EndValues[i],Series1.YValues[i]);
  end;
end;

Posted: Wed Sep 20, 2006 9:09 am
by 9347181
Thanks Narcis!

You are a Great help :D

Posted: Wed Sep 20, 2006 12:12 pm
by 9347181
Hi Narcis,
Your suggestion works fine but I am running into a problem with the Left Axis Text. When I enter a new series into the Gantt Chart the previous series scrolls up but the text remains in the same position on the Left Axis. What do I have to do to get the text to scroll with the series?

Posted: Wed Sep 20, 2006 12:33 pm
by narcis
Hi CCRyder,

I'm not sure on how to reproduce this. Could you please send us an example we can run "as-is" or some code to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

Thanks in advance.

Posted: Wed Sep 20, 2006 12:36 pm
by 9347181
Hi Narcis,
I guess I was a little fast on my last question. The Inserted Series appears above the previous series due to the sequence numbers that I am calculating. The problem is that for some reason the Bar Labels are not being inserted on the Left Axis.

Posted: Wed Sep 20, 2006 1:04 pm
by narcis
Hi CCRyder,

Sorry but I still don't know how to reproduce this issue. Could you please send us an example project, some code or further information on how to reproduce the problem here?

Thanks in advance.

Posted: Thu Sep 21, 2006 9:51 am
by narcis
Hi CCRyder,

This is because only the labels for the first series in the chart are drawn. To achieve what you request you should use custom labels as shown in the “All Features\Welcome!\Axes\Labels\Custom Labels” example in the features demo available at TeeChart’s program group.

Also find attached the modified project at the attachments newsgroup.

Posted: Thu Sep 21, 2006 10:29 am
by 9347181
Hi Narcis,
Your solution works great!!

Thanks!