TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
phocasdev
- Newbie
- Posts: 3
- Joined: Tue Mar 20, 2012 12:00 am
Post
by phocasdev » Thu Sep 27, 2012 6:41 am
My application charts a dataset and allows the user to choose the chart type from a list; bar, area, line and pie. They can double-click any of the series to see the data in another form. The bar, area and line charts work just fine. The pie one doesn't and it seems that the 'OnClickSeries' event doesn't fire. This 100% definitely used to work in an older version of TChart, but the current (v2112.06.120613) version does not.
I have tried setting the Series.OnClick instead (as per below code) of the Chart.OnClickSeries and it makes no difference - the procedure is never fired.
Any suggestions/solutions gratefully received.
Code snippet;
Code: Select all
// When creating the chart
for fnl := 0 to MyChart.SeriesCount-1 do
MyChart.Series[fnl].OnClick := ChartSeriesClick;
// Series OnClick.
procedure MyForm.ChartSeriesClick(Sender: TChartSeries; ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Sender is TPieSeries then
ClickValueVariable := Sender.ValueMarkText[ValueIndex]
else
ClickValueVariable := Sender.Title;
end;
-
Yeray
- Site Admin
- Posts: 9612
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Thu Sep 27, 2012 3:07 pm
Hi,
I'm trying to reproduce this with the code below but both the Series' OnClick event and the Clicked function in the OnMouseMove event seem to work fine for me here:
Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
with Chart1.AddSeries(TPieSeries) as TPieSeries do
begin
FillSampleValues;
OnClick:=SeriesOnClick;
end;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
//test 1
//Caption:=IntToStr(Chart1[0].Clicked(X,Y));
end;
procedure TForm1.SeriesOnClick(Sender: TChartSeries; ValueIndex: Integer; Button:TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
//test 2
Caption:=IntToStr(ValueIndex);
end;
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
-
phocasdev
- Newbie
- Posts: 3
- Joined: Tue Mar 20, 2012 12:00 am
Post
by phocasdev » Fri Sep 28, 2012 2:11 am
After cloning my code into a fresh project, I stumbled on the cause of the problem.
For TBarSeries, TAreaSeries and TLineSeries, the event OnClickBackground only fires when you click the background.
For TPieSeries, the OnClickBackground event fires all the time - overriding the OnClickSeries and the Series.OnClick.
-
Yeray
- Site Admin
- Posts: 9612
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Fri Sep 28, 2012 8:43 am
Hi,
I think I found what really makes the difference, at least for me here: the TeeCommander.
The code I posted
above behaves differently when you have or you haven't a TeeCommander on the form. Is it possible that you are using a TeeCommander too?
Having a TeeCommander on the form, when you click on the TPieSeries you can drag the clicked slice to explode it. When you've entered in this "mode", these two events (OnClickSeries and the Series.OnClick) aren't checked.
You can disable this "mode" with:
Code: Select all
TeeCommander1.EnablePieExploding:=false;
Could you please confirm this is what is causing the problem for you?