Legend with check boxes--when are they clicked?
-
- Advanced
- Posts: 228
- Joined: Tue Aug 28, 2007 12:00 am
- Location: Oregon, USA
Legend with check boxes--when are they clicked?
I have a legend with check boxes turned on--I need to know when one of the check boxes is clicked. How can I know? (I can use the OnCLick event for the chart, but is there anything more narrow?)
Re: Legend with check boxes--when are they clicked?
Hi Ed,
The most accurate I can think right now would be something as following:
The most accurate I can think right now would be something as following:
Code: Select all
uses series, TeCanvas;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
Chart1.View3D:=false;
for i:=0 to 4 do
begin
Chart1.AddSeries(TPointSeries.Create(self));
Chart1[i].FillSampleValues();
end;
Chart1.Legend.CheckBoxes:=true;
end;
procedure TForm1.Chart1ClickLegend(Sender: TCustomChart;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var i: Integer;
tmpPnt: TPoint;
tmpRect: TRect;
begin
tmpPnt.X:=X;
tmpPnt.Y:=Y;
for i:=0 to Chart1.SeriesCount-1 do
begin
tmpRect.Left:=Chart1.Legend.Left;
tmpRect.Right:=Chart1.Legend.Left + Chart1.Legend.Width - 1;
tmpRect.Bottom:=Chart1.Legend.Item[i].Top + Chart1.Legend.Item[i].SymbolRect.Bottom - Chart1.Legend.Item[i].SymbolRect.Top + 3;
if (i = 0) then tmpRect.Top:=Chart1.Legend.Item[i].Top-3
else tmpRect.Top:=Chart1.Legend.Item[i].Top-2;
if PtInRect(tmpRect,tmpPnt) then
begin
showmessage('series ' + IntToStr(i+1));
break;
end;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |