Page 1 of 1

How to detect pie slice on mouse move

Posted: Fri Apr 08, 2011 4:17 pm
by 16859007
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);

Re: How to detect pie slice on mouse move

Posted: Mon Apr 11, 2011 2:21 pm
by yeray
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;

Re: How to detect pie slice on mouse move

Posted: Mon Apr 11, 2011 4:03 pm
by 16859007
Thanks.