Page 1 of 1
[TSeriesBandTool] How to know when X,Y is in seriesBandTool?
Posted: Wed Nov 14, 2007 9:36 am
by 9343260
Hello,
Is there a easy and quick way to know if a coordinate X,Y (chart pixels) are inside a TSeriesBandTool area ?
Posted: Wed Nov 14, 2007 11:09 am
by yeray
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;
Posted: Thu Nov 15, 2007 10:01 am
by 9343260
Great, it works well, thanks.