Page 1 of 1

TDragPointTool always favoures the "left" point

Posted: Fri Apr 25, 2014 3:26 pm
by 16558331
Hi!
I'm using a TChart with one LineSeries and a TDragPointTool but grapping the series and moving the point (I just allow moving it in Y-direction) always uses the point left of the mouse-position (in the example image, if you grap the series one pixel to the left of the y:0-mark you begin to move the y:-1 mark!!).

I think it would be good to have an option to either restrain the drag-operation to the mark itself or center the sensitiv area over a point (eg.: -0.5 to 0.5 move the y:0-mark).

I'm also missing an option to restrict movement beyond some values (like the minima/maxima of the left axis in the example). Maybe an OnDragPointAllow(Sender, Index, Var Cancel: Boolean) - event could be implemented?

Re: TDragPointTool always favoures the "left" point

Posted: Mon Apr 28, 2014 7:36 am
by yeray
Hello,
Whookie wrote:I'm using a TChart with one LineSeries and a TDragPointTool but grapping the series and moving the point (I just allow moving it in Y-direction) always uses the point left of the mouse-position (in the example image, if you grap the series one pixel to the left of the y:0-mark you begin to move the y:-1 mark!!).

I think it would be good to have an option to either restrain the drag-operation to the mark itself or center the sensitiv area over a point (eg.: -0.5 to 0.5 move the y:0-mark).
I've added it to the wish list to be further investigated. I think looking for what of the two valueindex of the clicked line segment is the nearest to the mouse click should work better:
http://bugs.teechart.net/show_bug.cgi?id=748
Feel free to add you mail to the CC list to be automatically notified when an update arrives.
Whookie wrote:I'm also missing an option to restrict movement beyond some values (like the minima/maxima of the left axis in the example). Maybe an OnDragPointAllow(Sender, Index, Var Cancel: Boolean) - event could be implemented?
There's a OnDragPoint event for the TDragPointTool you could use to restrict this. Ie:

Code: Select all

var tmpMin, tmpMax: Double;

procedure TForm1.FormCreate(Sender: TObject);
begin
  tmpMin:=Chart1[0].YValues.MinValue;
  tmpMax:=Chart1[0].YValues.MaxValue;
end;

procedure TForm1.ChartTool1DragPoint(Sender: TDragPointTool;
  Index: Integer);
begin
  if ((Index>-1) and (Chart1[0].YValue[Index]>=tmpMax)) then
    Chart1[0].YValue[Index]:=tmpMax;

  if ((Index>-1) and (Chart1[0].YValue[Index]<=tmpMin)) then
    Chart1[0].YValue[Index]:=tmpMin;
end;