Page 1 of 1

Getting the name of a Slice in a Pie Chart

Posted: Sat Mar 04, 2017 7:14 pm
by 16880166
I am brand new to Tee Chart so first, i appologise for my terms in this question.

I am trying to return the name of a Slice of a Pie chart or a Bar Chart when a customer double clicks it. I want to use this name to edit my SQL to show a new chart based on the name of the slice double clicked. I use the following code to return the Series and Point on the chart, but I need a way of converting the point to a name. I know this must be a very basic question but didn't find an answer by searching.

Code: Select all

procedure TMainForm.DBChart1DblClick(Sender: TObject);
var t,tmp : Integer;
    x,y   : Double;
begin
  Series1.GetCursorValues(x,y);
  for t:=0 to DBChart1.SeriesCount-1 do
  begin
    tmp:=DBChart1.Series[t].GetCursorValueIndex;
    if tmp<>-1 then
       ShowMessage(' Clicked Series: '+DBChart1.Series[t].Name+' at point: '+inttostr(tmp));
  end;
I hope this makes sense. Thanks.

Re: Getting the name of a Slice in a Pie Chart

Posted: Sat Mar 04, 2017 8:22 pm
by 16880166
Found the answer. Sorry guys. This is my first day using the component:

Code: Select all

procedure TMainForm.DBChart1DblClick(Sender: TObject);
var t,tmp : Integer;
    x,y   : Double;
begin
  Series1.GetCursorValues(x,y);
  for t:=0 to DBChart1.SeriesCount-1 do
  begin
    tmp:=DBChart1.Series[t].GetCursorValueIndex;
    if tmp<>-1 then
       ShowMessage(' Clicked Series: '+DBChart1.Series[t].Name+' at point: '+ Series1.Labels[tmp]);
  end;
end;