"tolerace" for clicked line

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Tom
Newbie
Newbie
Posts: 7
Joined: Tue Apr 27, 2004 4:00 am

"tolerace" for clicked line

Post by Tom » Sat May 29, 2004 3:45 pm

I have a Line Series that I want the user to be able to click on and
then I will display some values. The problem is that the line is
very hard to position the mouse over. Customers with unsteady hands
complain it is impossible to place the cursor over the line.

Is there a way to trigger the OnClick routine if the mouse is clicked
within - say 10 pixels?

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

Post by Pep » Mon May 31, 2004 12:07 am

Hi Tom,

how about using the following code to retrieve and show the values from the series on the Canvas by clicking it ? :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(10);
Chart1.View3D := False;
end;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var tmp, tmpL,x1,y1 : Integer;
begin
  With Chart1 do
  begin
    for x1 := 0 to 10 do
      for y1 := 0 to 10 do
      begin
        If (Series1.Clicked(X+x1, Y+y1) <> -1) And (OnSeriesPoint = False) Then
        begin
         Canvas.Brush.Style := bsSolid;
         Canvas.Pen.Color := clBlack;
         Canvas.Brush.Color := clWhite;
         canvas.TextOut(x+10,y,FormatFloat('#.00',Series1.XScreenToValue(x))+','+FormatFloat('#.00',Series1.YScreenToValue(y)));
         OnSeriesPoint := True;
        End;
        If (Series1.Clicked(X+x1, Y+y1) = -1) And (OnSeriesPoint = True) Then
          OnSeriesPoint := False;
      end;
  End;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
Chart1.Repaint;
end;

Tom
Newbie
Newbie
Posts: 7
Joined: Tue Apr 27, 2004 4:00 am

Post by Tom » Mon May 31, 2004 3:12 pm

Worked great. Thanks

Post Reply