Addressing individual Gantt bars

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Jon
Newbie
Newbie
Posts: 2
Joined: Thu Apr 15, 2004 4:00 am
Location: Sweden

Addressing individual Gantt bars

Post by Jon » Tue Aug 02, 2005 9:36 am

When creating a bar in a Gantt diagram with e.g. AddGanttColor, the function returns a index value as, according to the help file, can be used to address the bar.

When I create multiple bars on each line, the returned index value is re-used sometimes (have not figured out the pattern) and is therefore not useable for identifying each individual bar. Why is that? Have I misunderstood the concept of the returned index value?

What I need is to be able to identify what individual bar is being clicked. Is there a way of accomplishing this by other means than the above mentioned index value?

Thanks!
Jon

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Aug 02, 2005 10:36 am

Hi Jon,
What I need is to be able to identify what individual bar is being clicked. Is there a way of accomplishing this by other means than the above mentioned index value?
Yes, you could use the OnClick event of the Gantt Series, which returns the ValueIndex of the gantt clicked, or you can use the Clicked method :

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  var  clickedIndex : integer;
begin
  ClickedIndex := Series1.Clicked(x,y);
  ShowMessage(inttostr(ClickedIndex));
  abort;
end;
Maybe what you're trying to accomplish is similar to the Gantt Drag Tool ? Have you seen it ? You can find one example in the Demo Features project.

Jon
Newbie
Newbie
Posts: 2
Joined: Thu Apr 15, 2004 4:00 am
Location: Sweden

Post by Jon » Tue Aug 02, 2005 12:28 pm

Hi Pep,

Thanks for the reply.

Meanwhile, I found this explanation (through Google Groups search) to the strange index numbers:

>David Berneda 23 Mar 1998 10:00 wrote:
>
>By default, Gantt series sort points by X values.
>Disabling X sorting ( or calling AddGantt with X values sorted ) will >maintain the index numbers.
>
>Series1.XValues.Order := loNone ;
>Series1.AddGantt...
>Series1.AddGantt...
>
>In your code, the second gantt bar has a lower X value than the
>first. So that's why the index is zero in the two cases.

This worked for me and gave me some relief this afternoon. 8)

Thanks again!
Jon

Post Reply