Reputation: 67
In a small Delphi program I create few TCharts and TBarSeries programmatically on the runtime but then I want to be able to click on a bar of the chart and fire, for example, a Chart1ClickSeries event to display information of that bar. Is that possible??
Upvotes: 0
Views: 176
Reputation: 3801
First, create your event handler:
TForm1 = class...
...
procedure BarSeries1Click(Sender: TChartSeries;
ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
procedure BarSeries1DblClick(Sender: TChartSeries;
ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
...
end;
procedure TForm1.BarSeries1Click(Sender: TChartSeries;
ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
ShowMessage('Click');
end;
procedure TForm1.BarSeries1DblClick(Sender: TChartSeries;
ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
ShowMessage('DblClick');
end;
Then after you've created your Series, assign the events:
BarSeries1.OnClick:=BarSeries1Click;
BarSeries1.OnDblClick:=BarSeries1DblClick;
Upvotes: 2