GANTT chart automatic reposition (TeeChart Pro 6.01)

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
GEINFOR
Newbie
Newbie
Posts: 3
Joined: Fri Nov 15, 2002 12:00 am

GANTT chart automatic reposition (TeeChart Pro 6.01)

Post by GEINFOR » Thu Jun 05, 2008 4:43 pm

In a GANTT chart I have added the possibility to reposition and to resize the bars of the graphic with TGanttTool component, but I have two problems:

(1) If there are different bars/tasks of the GANTT chart connected among them, when I reposition or resize a bar, the other connected bars are not repositioned automatically. If I move a bar that represents a task to perform until its end finish after the start of the following task to perform, that the following tasks are not repositioned automatically to start just in the end of the prevoius task. This automatic repositioning is possible to perform with the component?


(2) I need to show a popup menu when press rightclick mouse button on a concrete bar. The problem is that, when select a menu item, the bar is repositioned while moves the mouse pointer, and it's necessary to click again to finish the repositioning.
I try to avoid this bad functionality deactivating drag and resize, but without success. I show you an example:

Code: Select all

procedure TForm1.SerieGanttClick(Sender: TChartSeries; ValueIndex: Integer;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
 if Button = mbRight then
 begin
  Gantt.AllowDrag := False;
  Gantt.AllowResize := False;
  Try
  PopupMenu.PopUp(X, Y + 100);
  Finally
   Gantt.AllowDrag := True;
   Gantt.AllowResize := True;
  End;
 end;
end;

It is possible to deactivate this funcionality when show a popup menu and select an item without the repositioning problem?

Regards

Jose

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Fri Jun 06, 2008 8:52 am

Hi Jose,

1) I think you should use OnDragBar and OnResizeBar events from your Gantt Tool to explore the whole Gantt series and modify start or end values when they are superposed. I think you should do something like following. But note that it's not completed, but maybe it's a good start.

Code: Select all

procedure TForm1.ChartTool1ResizeBar(Sender: TGanttTool; GanttBar: Integer;
  BarPart: TGanttToolBarPart);
var i: Integer;
wide: Double;
begin
  with Series1 do
  begin
    for i:=0 to Series1.Count-1 do
    begin
      if (StartValues.Items[i] > StartValues.Items[GanttBar]) and (StartValues.Items[i] < EndValues.Items[GanttBar]) then
      begin
        wide := EndValues.Items[i] - StartValues.Items[i];
        StartValues.Items[i] := EndValues.Items[GanttBar];
        EndValues.Items[i] := StartValues.Items[i] + wide;
      end;
    end;
  end;
end;
2) I've tried what you say and achieved it with OnClickSeries and OnMouseDown events. I think that your problem here was that the Gantt series started to drag/resize before disabling the functionalities.

Code: Select all

procedure TForm1.Series1Click(Sender: TChartSeries; ValueIndex: Integer;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Button = mbRight then
  begin
    ChartTool1.AllowDrag := True;
    ChartTool1.AllowResize := True;
  end;
end;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (Button = mbRight) and (Series1.Clicked(X,Y) >= 0) then
  begin
    ChartTool1.AllowDrag := False;
    ChartTool1.AllowResize := False;

    Try
      ShowMessage('okay');
    finally
    end;
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

GEINFOR
Newbie
Newbie
Posts: 3
Joined: Fri Nov 15, 2002 12:00 am

Post by GEINFOR » Fri Jun 06, 2008 11:36 am

Hi Yeray!

Point 2 is solved. Thanks!!!!

About point 1, I see that if reposition one bar, change all bars according init bar position. I think that the better way is to reposition all bars that depend on bar repositioned/resized when the user release the mouse button (in the mouse up event).

There are an easy way to access all bars that depends of one bar, and reposition recursively from one bar to forward?

Thanks in advance

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Jun 06, 2008 1:27 pm

Hi GEINFOR,
There are an easy way to access all bars that depends of one bar, and reposition recursively from one bar to forward?
Yes, you can use NextTask property. You can find an eample using NextTask on this thread.

Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

GEINFOR
Newbie
Newbie
Posts: 3
Joined: Fri Nov 15, 2002 12:00 am

Post by GEINFOR » Fri Jun 06, 2008 3:58 pm

Ok, Narcís. Moltes gràcies.

Jose

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Jun 09, 2008 7:08 am

Hola Jose,

De res! :wink:
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply