mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-16 01:20:10 +02:00
TAChart: new property "MouseInsideOnly" of TDatapointHintTool and TDataPointCrosshairTool to show the hint/crosshair only if mouse is inside the chart's extent.
git-svn-id: trunk@48089 -
This commit is contained in:
parent
6c7790212c
commit
6807ed5497
@ -398,6 +398,7 @@ type
|
|||||||
FAffectedSeries: TPublishedIntegerSet;
|
FAffectedSeries: TPublishedIntegerSet;
|
||||||
FDistanceMode: TChartDistanceMode;
|
FDistanceMode: TChartDistanceMode;
|
||||||
FGrabRadius: Integer;
|
FGrabRadius: Integer;
|
||||||
|
FMouseInsideOnly: Boolean;
|
||||||
function GetAffectedSeries: String; inline;
|
function GetAffectedSeries: String; inline;
|
||||||
function GetIsSeriesAffected(AIndex: Integer): Boolean; inline;
|
function GetIsSeriesAffected(AIndex: Integer): Boolean; inline;
|
||||||
procedure SetAffectedSeries(AValue: String); inline;
|
procedure SetAffectedSeries(AValue: String); inline;
|
||||||
@ -407,6 +408,8 @@ type
|
|||||||
FPointIndex: Integer;
|
FPointIndex: Integer;
|
||||||
FSeries: TBasicChartSeries;
|
FSeries: TBasicChartSeries;
|
||||||
procedure FindNearestPoint(APoint: TPoint);
|
procedure FindNearestPoint(APoint: TPoint);
|
||||||
|
property MouseInsideOnly: Boolean
|
||||||
|
read FMouseInsideOnly write FMouseInsideOnly default false;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
public
|
public
|
||||||
@ -504,11 +507,12 @@ type
|
|||||||
property OnHintLocation: TChartToolHintLocationEvent
|
property OnHintLocation: TChartToolHintLocationEvent
|
||||||
read FOnHintLocation write FOnHintLocation;
|
read FOnHintLocation write FOnHintLocation;
|
||||||
property OnHintPosition: TChartToolHintPositionEvent
|
property OnHintPosition: TChartToolHintPositionEvent
|
||||||
read FOnHintPosition write FOnHintPosition; //deprecated;
|
read FOnHintPosition write FOnHintPosition;
|
||||||
property UseApplicationHint: Boolean
|
property UseApplicationHint: Boolean
|
||||||
read FUseApplicationHint write SetUseApplicationHint default false;
|
read FUseApplicationHint write SetUseApplicationHint default false;
|
||||||
property UseDefaultHintText: Boolean
|
property UseDefaultHintText: Boolean
|
||||||
read FUseDefaultHintText write FUseDefaultHintText default true;
|
read FUseDefaultHintText write FUseDefaultHintText default true;
|
||||||
|
property MouseInsideOnly;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TDataPointDrawTool }
|
{ TDataPointDrawTool }
|
||||||
@ -534,6 +538,7 @@ type
|
|||||||
property DrawingMode;
|
property DrawingMode;
|
||||||
property GrabRadius default 20;
|
property GrabRadius default 20;
|
||||||
property OnDraw: TChartDataPointDrawEvent read FOnDraw write FOnDraw;
|
property OnDraw: TChartDataPointDrawEvent read FOnDraw write FOnDraw;
|
||||||
|
property MouseInsideOnly;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TChartCrosshairShape = (ccsNone, ccsVertical, ccsHorizontal, ccsCross);
|
TChartCrosshairShape = (ccsNone, ccsVertical, ccsHorizontal, ccsCross);
|
||||||
@ -1570,9 +1575,19 @@ procedure TDataPointTool.FindNearestPoint(APoint: TPoint);
|
|||||||
function InBoundaryBox(ASeries: TCustomChartSeries): Boolean;
|
function InBoundaryBox(ASeries: TCustomChartSeries): Boolean;
|
||||||
var
|
var
|
||||||
r, gr: TDoubleRect;
|
r, gr: TDoubleRect;
|
||||||
|
p: TDoublePoint;
|
||||||
|
ext: TDoubleRect;
|
||||||
begin
|
begin
|
||||||
r := ASeries.GetGraphBounds;
|
r := ASeries.GetGraphBounds;
|
||||||
if not RectIntersectsRect(r, FChart.CurrentExtent) then exit(false);
|
ext := FChart.CurrentExtent;
|
||||||
|
if not RectIntersectsRect(r, ext) then exit(false);
|
||||||
|
|
||||||
|
if FMouseInsideOnly then begin
|
||||||
|
p := FChart.ImageToGraph(APoint);
|
||||||
|
if not (SafeInRange(p.x, ext.a.x, ext.b.x) and SafeInRange(p.y, ext.a.y, ext.b.y)) then
|
||||||
|
exit(false);
|
||||||
|
end;
|
||||||
|
|
||||||
case DistanceMode of
|
case DistanceMode of
|
||||||
cdmOnlyX: begin
|
cdmOnlyX: begin
|
||||||
gr.a := DoublePoint(FChart.XImageToGraph(APoint.X - GrabRadius), NegInfinity);
|
gr.a := DoublePoint(FChart.XImageToGraph(APoint.X - GrabRadius), NegInfinity);
|
||||||
|
Loading…
Reference in New Issue
Block a user