I am investigating Using DragPoint in a Gantt Chart on the Y axis. This works well but I would like to be able so enable a 'SnapTo' or Step feature rather than the smooth linear result I am getting from the DragPoint at the moment.
I have seen the 'Desired Increment' on the Left Axis but regrettably this doesn't appear to do what I want.
Any suggestions for a work around and any samples of using the Gantt chart in more depth would be much appreciated.
Best Wishes
Tony Hunt
Using DragPoint in a Gantt Chart
Re: Using DragPoint in a Gantt Chart
Hi Tony,
There is the Gantt Drag tool that allows dragging but without allowing you to set the tolerance you wish.
Here you have an example of how you could do something like what you requested without any tool, directly using OnMouseDown, OnMouseUp and OnMouseMove events:
There is the Gantt Drag tool that allows dragging but without allowing you to set the tolerance you wish.
Here you have an example of how you could do something like what you requested without any tool, directly using OnMouseDown, OnMouseUp and OnMouseMove events:
Code: Select all
var
Form1: TForm1;
DraggingIndex, DraggingTolerance, StartX: Integer;
OldStartValue, OldEndValue: Double;
series1: TGanttSeries;
implementation
{$R *.dfm}
procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
DraggingIndex := -1;
end;
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
DraggingIndex := Series1.Clicked(X, Y);
if (DraggingIndex>-1) then
begin
StartX := X;
OldStartValue := series1.StartValues.Items[DraggingIndex];
OldEndValue := series1.EndValues.Items[DraggingIndex];
end;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var movedValues: double;
begin
if (Series1.Clicked(X, Y) <> -1) then
begin
Chart1.Cursor := crHandPoint;
Chart1.CancelMouse := True;
end;
if (DraggingIndex>-1) then
begin
movedValues := Abs(Chart1.Axes.Bottom.CalcPosPoint(X))-Abs(Chart1.Axes.Bottom.CalcPosPoint(StartX));
series1.StartValues.Items[DraggingIndex] := OldStartValue + round(movedValues / DraggingTolerance)*DraggingTolerance;
series1.EndValues.Items[DraggingIndex] := OldEndValue + round(movedValues / DraggingTolerance)*DraggingTolerance;
Chart1.Title.Text.Text := floattostr(X-StartX);
Chart1.Draw;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D := false;
Chart1.AllowZoom := false;
series1 := TGanttSeries.Create(self);
Chart1.AddSeries(series1);
series1.FillSampleValues(6);
DraggingIndex := -1;
DraggingTolerance := 5;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Using DragPoint in a Gantt Chart
Thank you very much, that gave me a good insight into several other things as well.
Tony
Tony