[TSeriesBandTool] How to know when X,Y is in seriesBandTool?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

[TSeriesBandTool] How to know when X,Y is in seriesBandTool?

Post by bertrod » Wed Nov 14, 2007 9:36 am

Hello,

Is there a easy and quick way to know if a coordinate X,Y (chart pixels) are inside a TSeriesBandTool area ?

Yeray
Site Admin
Site Admin
Posts: 9533
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Wed Nov 14, 2007 11:09 am

Hi bertrod,

We've made an example of how you can achieve this in a not very complicated way. In a few words it consists on search up for a series, and down for another one when the chart is clicked.

And also note that we've added to our wish-list the request to implement Clicked method for TSeriesBandTool in future releases.

Code: Select all

type
...
private
    { Private declarations }
    function SeriesClicked(X,Y: Integer): Boolean;
...
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var CursorUp, CursorDown: Integer;
begin
  for CursorUp:=Y downto Chart1.ChartRect.Top do
  begin
    if SeriesClicked(X, CursorUp) then
    begin
        for CursorDown:=Y to Chart1.ChartRect.Bottom do
          if SeriesClicked(X, CursorDown) then
          begin
            Chart1.Title.Text[0]:='Point in SeriesBand';
            break;
          end
          else
            Chart1.Title.Text[0]:='Point NOT in SeriesBand';

        break;
    end
    else
      Chart1.Title.Text[0]:='Point NOT in SeriesBand';
  end;
end;

function TForm1.SeriesClicked(X, Y: Integer): Boolean;
begin
  result:=((Series1.Clicked(X, Y)<>-1) or (Series2.Clicked(X, Y)<>-1));
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Thu Nov 15, 2007 10:01 am

Great, it works well, thanks.

Post Reply