Hi
How to find out when mouse is over an mark and get information which chart and which data point.
I only show the mark of the series and I want to show an hint when mouse is over an mark.
There should show a sepperate hint for each mark.
many thanks for helping.
Best Regards
Mandi
Get MouseOver when mouse is over a mark
-
- Newbie
- Posts: 3
- Joined: Fri Dec 07, 2007 12:00 am
Re: Get MouseOver when mouse is over a mark
Hi Mandi,
You could do something like in the following example:
You could do something like in the following example:
Code: Select all
uses series, TeeTools;
var series1: TBarSeries;
annotation1: TAnnotationTool;
procedure TForm1.FormCreate(Sender: TObject);
begin
series1 := TBarSeries.Create(self);
Chart1.AddSeries(series1);
series1.FillSampleValues(6);
annotation1 := TAnnotationTool.Create(self);
Chart1.Tools.Add(annotation1);
annotation1.Active := false;
Chart1.Draw;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var i, j: Integer;
p: TPoint;
r: TRect;
begin
p.X := X;
p.Y := Y;
for i:=0 to Chart1.SeriesCount-1 do
for j:=0 to Chart1[i].Count-1 do
begin
r.Left := Chart1[i].Marks.Positions[j].LeftTop.X;
r.Top := Chart1[i].Marks.Positions[j].LeftTop.Y;
r.Right := Chart1[i].Marks.Positions[j].LeftTop.X + Chart1[i].Marks.Positions[j].Width;
r.Bottom := Chart1[i].Marks.Positions[j].LeftTop.Y + Chart1[i].Marks.Positions[j].Height;
if PtInRect(r, p) then
begin
annotation1.Left := r.Right + 5;
annotation1.Top := r.Top;
annotation1.Text := 'value number ' + inttostr(j);
annotation1.Active := True;
Exit;
end
else
annotation1.Active := False;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |