Page 1 of 1

Multiple Pies (Concentric) mouse click not function

Posted: Tue Oct 04, 2016 9:46 am
by 16577003
Current using BDS2006,

When i apply 2 pie series with (Concentric), Series1 and Series2, I have handled OnClick event for both series but only Series2(Outer Pie) OnClick will be triggered. I have tried to handle TChart.OnClickSeries, but regardless of which series I am clicking, in OnClickSeries event, the sender is always Series2(Outer Pie). Any idea on how can I handle OnClick event for both Pies?

Thanks

Re: Multiple Pies (Concentric) mouse click not function

Posted: Tue Oct 04, 2016 1:26 pm
by yeray
Hello,

You could use OnMouseDown event and call the clicked function of both series in it. Ie:

Code: Select all

uses Series;

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

  for i:=0 to 1 do
  with Chart1.AddSeries(TPieSeries) as TPieSeries do
  begin
    MultiPie:=mpConcentric;
    FillSampleValues();
  end;

  Chart1.OnMouseDown:=ChartMouseDown;

  Memo1.Clear;
end;

procedure TForm1.ChartMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
                                X, Y: Integer);
var SeriesIndex,
    ValueIndex:  Integer;
begin
  for SeriesIndex:=0 to Chart1.SeriesCount-1 do
  begin
    ValueIndex:=Chart1[SeriesIndex].Clicked(X,Y);
    if ValueIndex>-1 then
      Memo1.Lines.Add('OnMouseDown event, '+SeriesTitleOrName(Chart1[SeriesIndex])+', ValueIndex: '+IntToStr(ValueIndex));
  end;
end;