How to delete a fibonacci object

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
sswang
Newbie
Newbie
Posts: 24
Joined: Wed Mar 28, 2012 12:00 am

How to delete a fibonacci object

Post by sswang » Mon May 13, 2013 9:21 am

Hi,

There are multiple TFibonacciTool objects on my chart.
Is there a way to perform delete operation by clicking one of them? thanks.

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

Re: How to delete a fibonacci object

Post by Yeray » Mon May 13, 2013 11:45 am

Hi,

At the moment there isn't a clicked function for the TFibonacciTool. I've added it to the wish list to be implemented in future releases (TV52016571).
In the meanwhile you could try to do it manually.
Here it is an example that works for a series with multiple TFibonacciTools. However in this example I'm only calculating if the trending line is being clicked, not for the levels. For the levels you'll have to loop the levels, calculate the lines where they are drawn and check them as I do for the trend line.

Code: Select all

var MDown: TPoint;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;

  Chart1.AddSeries(TCandleSeries).FillSampleValues(35);

  for i:=0 to 2 do
  begin
    with Chart1.Tools.Add(TFibonacciTool) as TFibonacciTool do
    begin
      StartX:=(Chart1[0] as TCandleSeries).DateValues[i*10];
      StartY:=(Chart1[0] as TCandleSeries).CloseValues[i*10];
      EndX:=(Chart1[0] as TCandleSeries).DateValues[(i+1)*10];
      EndY:=(Chart1[0] as TCandleSeries).CloseValues[(i+1)*10];
      DrawStyle:=fsRetracement;
    end;
  end;
end;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  MDown.X:=X;
  MDown.Y:=Y;
end;

procedure TForm1.Chart1Click(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Chart1.Tools.Count-1 do
  if Chart1.Tools[i] is TFibonacciTool then
  with Chart1.Tools[i] as TFibonacciTool do
  begin
    if ((DrawStyle=fsFan) or (DrawStyle=fsArc)) then
    begin
      if PointInLine(MDown, Chart1.Axes.Bottom.CalcPosValue(StartX), Chart1.Axes.Left.CalcPosValue(StartY),
                     Chart1.Axes.Bottom.CalcPosValue(EndX), Chart1.Axes.Left.CalcPosValue(EndY)) then
      begin
        Active:=false;
        exit;
      end;

      if DrawStyle=fsFan then
      begin
      end
      else //DrawStyle=fsArc
      begin
      end;
    end
    else
    begin //DrawStyle=fsRetracement
      if PointInLine(MDown, Chart1.Axes.Bottom.CalcPosValue(StartX), Chart1.Axes.Left.CalcPosValue(StartY),
                     Chart1.Axes.Bottom.CalcPosValue(EndX), Chart1.Axes.Left.CalcPosValue(StartY)) or
         PointInLine(MDown, Chart1.Axes.Bottom.CalcPosValue(StartX), Chart1.Axes.Left.CalcPosValue(EndY),
                     Chart1.Axes.Bottom.CalcPosValue(EndX), Chart1.Axes.Left.CalcPosValue(EndY)) then
      begin
        Active:=false;
        exit;
      end;
    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

sswang
Newbie
Newbie
Posts: 24
Joined: Wed Mar 28, 2012 12:00 am

Re: How to delete a fibonacci object

Post by sswang » Tue May 14, 2013 3:39 am

Nice! Thanks.

Post Reply