Page 1 of 1

using hit test on TeeChart

Posted: Wed Feb 28, 2007 9:57 am
by 9343215
In the past I had used something like hit test to find the sub part of the chart under the cursor but have forgotton the exact details.

Also am not able to find any thing related to it in latest demo/examples etc. I am using TeeChart pro 7.07

Kindly help.

Regards

Posted: Wed Feb 28, 2007 10:51 am
by narcis
Hi Corey,

Sorry but I don't understand what are you exactly trying to achieve here. Could you please give us more detailed information on what are you trying to get?

Thanks in advance.

trying to find region under mouse

Posted: Thu Mar 01, 2007 11:55 am
by 9343215
Dear NarcĂ­s

Thanks for your kind reply.

Actually, I ws trying to get around another problem (TeeLineSeparator not working in displayed Series Titles in the graph).

I was thinking that if I can track the mouse cursor then atleast I can pop up some sort of hint with the full Series title because sometimes it gets truncated on the right side (if its length exceeds that of remaining width of TChart component).

for the above, I need to first of know as when the user is bringing mouse cursor over the series title .

Thanking you in advance in anticipation

with warm Regards

Posted: Thu Mar 01, 2007 12:12 pm
by narcis
Hi Corey,

To check if the mouse is over the chart's title you can use OnMouseMove event and something like this:

Code: Select all

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if Chart1.Title.Clicked(X,Y) then
  begin
    //Put your hint code here.
  end;
end;
For the hint, I suggest you to use annotation tools as told here.

but it does not works for series titles

Posted: Thu Mar 01, 2007 12:49 pm
by 9343215
Thanks once again for your kind reply but it does not works for the Series titles.

Please suggest some other alternatives.

I remeber using some sort of hit-detection in past, but am not able to get the details right. just as on TTreeview component, you can check if mouse cursor if over the button or image or text etc, same thing was somehow available in TChart also to know if the cursor is over the legend or title or axis etc etc.

Regards

Posted: Thu Mar 01, 2007 2:01 pm
by narcis
Hi Corey,

I'm afraid I didn't understood what you were looking for. To display series title you may be interested in using TMarkTipsTool and use its OnGetText event doing something like this:

Code: Select all

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var i: Integer;
begin
  for i:=0 to Chart1.SeriesCount-1 do
    if Chart1[i].Clicked(X,Y)<>-1 then
    begin
      SeriesIndex:=i;
      break;
    end;
end;

procedure TForm1.ChartTool1GetText(Sender: TMarksTipTool;
  var Text: String);
begin
  Text:=Chart1[SeriesIndex].Name;
  //or
  //Text:=Chart1[SeriesIndex].Title;
end;