Identify which chart send OnClick event

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
JEL56
Newbie
Newbie
Posts: 2
Joined: Wed Jan 04, 2017 12:00 am

Identify which chart send OnClick event

Post by JEL56 » Fri Feb 17, 2017 6:44 pm

Dear reader,

I am developing a statistical application that performs clustering. Based on user input the program calculates a number of clusters and graphs the results. The charts are dynamically created at runtime and the number of graphs is not known in advance (varies from 2 - 50). The program works quite nicely but the charts lack support for user interaction. I want to be able to click on any of the charts and assign that chart to the TeeCommander for saving or editing. How can I identify/capture which of the charts triggered an OnClick event? Thank you for your support.

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

Re: Identify which chart send OnClick event

Post by Yeray » Mon Feb 20, 2017 1:57 pm

Hello,

The TChart's OnClick event gives you the TChart that "sent" the event. So you can assign that Sender to the TTeeCommander's Panel property. Ie:

Code: Select all

uses Chart;

var Charts: array of TChart;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Setlength(Charts, 3);

  for i:=0 to High(Charts) do
  begin
    Charts[i]:=TChart.Create(Self);
    Charts[i].Parent:=Self;
    Charts[i].Align:=alTop;
    Charts[i].OnClick:=ChartOnClick;
  end;
end;

procedure TForm1.ChartOnClick(Sender: TObject);
begin
  TeeCommander1.Panel:=Sender as TChart;
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

JEL56
Newbie
Newbie
Posts: 2
Joined: Wed Jan 04, 2017 12:00 am

Re: Identify which chart send OnClick event

Post by JEL56 » Tue Feb 21, 2017 4:38 pm

This works great! Thank you Yeray!

Post Reply