How to detect pie slice on mouse move

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
rloewy
Newbie
Newbie
Posts: 5
Joined: Thu Apr 07, 2011 12:00 am

How to detect pie slice on mouse move

Post by rloewy » Fri Apr 08, 2011 4:17 pm

Hi,

Is there any way to detect what pie slice the mouse is over - the way we recognize it in the SeriesClick event for example - where the ValueIndex tells you the slice?

I want to use this to animate the slide the user is on by exploding it - for a more dynamic look.

procedure TForm5.Series1Click(Sender: TChartSeries; ValueIndex: Integer;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

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

Re: How to detect pie slice on mouse move

Post by Yeray » Mon Apr 11, 2011 2:21 pm

Hello,

You could use the Clicked event in the OnMouseMove event. Here it is an example of it:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TPieSeries).FillSampleValues();
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var ClickedIndex, i, tmp: Integer;
begin
  ClickedIndex:=Chart1[0].Clicked(X,Y);
  if ClickedIndex>-1 then
  begin
    for i:=0 to Chart1[0].Count-1 do
    begin
      if i=ClickedIndex then tmp:=15
      else tmp:=0;

      (Chart1[0] as TPieSeries).ExplodedSlice[i]:=tmp;
    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

rloewy
Newbie
Newbie
Posts: 5
Joined: Thu Apr 07, 2011 12:00 am

Re: How to detect pie slice on mouse move

Post by rloewy » Mon Apr 11, 2011 4:03 pm

Thanks.

Post Reply