mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 02:39:15 +02:00
TAChart: Add TRandomChartSource.YNanPercent property
git-svn-id: trunk@41770 -
This commit is contained in:
parent
26622f6def
commit
f0b282dbd0
@ -57,6 +57,8 @@ type
|
|||||||
|
|
||||||
TChartDistance = 0..MaxInt;
|
TChartDistance = 0..MaxInt;
|
||||||
|
|
||||||
|
TPercent = 0..100;
|
||||||
|
|
||||||
TPointDistFunc = function (const A, B: TPoint): Integer;
|
TPointDistFunc = function (const A, B: TPoint): Integer;
|
||||||
|
|
||||||
TTransformFunc = function (A: Double): Double of object;
|
TTransformFunc = function (A: Double): Double of object;
|
||||||
|
@ -96,6 +96,7 @@ type
|
|||||||
FXMin: Double;
|
FXMin: Double;
|
||||||
FYMax: Double;
|
FYMax: Double;
|
||||||
FYMin: Double;
|
FYMin: Double;
|
||||||
|
FYNanPercent: TPercent;
|
||||||
strict private
|
strict private
|
||||||
FCurIndex: Integer;
|
FCurIndex: Integer;
|
||||||
FCurItem: TChartDataItem;
|
FCurItem: TChartDataItem;
|
||||||
@ -108,6 +109,7 @@ type
|
|||||||
procedure SetXMin(AValue: Double);
|
procedure SetXMin(AValue: Double);
|
||||||
procedure SetYMax(AValue: Double);
|
procedure SetYMax(AValue: Double);
|
||||||
procedure SetYMin(AValue: Double);
|
procedure SetYMin(AValue: Double);
|
||||||
|
procedure SetYNanPercent(AValue: TPercent);
|
||||||
protected
|
protected
|
||||||
function GetCount: Integer; override;
|
function GetCount: Integer; override;
|
||||||
function GetItem(AIndex: Integer): PChartDataItem; override;
|
function GetItem(AIndex: Integer): PChartDataItem; override;
|
||||||
@ -127,6 +129,7 @@ type
|
|||||||
property YCount;
|
property YCount;
|
||||||
property YMax: Double read FYMax write SetYMax;
|
property YMax: Double read FYMax write SetYMax;
|
||||||
property YMin: Double read FYMin write SetYMin;
|
property YMin: Double read FYMin write SetYMin;
|
||||||
|
property YNanPercent: TPercent read FYNanPercent write SetYNanPercent default 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TUserDefinedChartSource = class;
|
TUserDefinedChartSource = class;
|
||||||
@ -740,7 +743,9 @@ function TRandomChartSource.GetItem(AIndex: Integer): PChartDataItem;
|
|||||||
|
|
||||||
function GetRandomY: Double;
|
function GetRandomY: Double;
|
||||||
begin
|
begin
|
||||||
if YMax <= YMin then
|
if (YNanPercent > 0) and (FRNG.GetInRange(0, 100) <= YNanPercent) then
|
||||||
|
Result := SafeNan
|
||||||
|
else if YMax <= YMin then
|
||||||
Result := YMin
|
Result := YMin
|
||||||
else
|
else
|
||||||
Result := FRNG.Get / High(LongWord) * (YMax - YMin) + YMin;
|
Result := FRNG.Get / High(LongWord) * (YMax - YMin) + YMin;
|
||||||
@ -754,7 +759,7 @@ begin
|
|||||||
FCurIndex := -1;
|
FCurIndex := -1;
|
||||||
end;
|
end;
|
||||||
while FCurIndex < AIndex do begin
|
while FCurIndex < AIndex do begin
|
||||||
Inc(FCurIndex);
|
FCurIndex += 1;
|
||||||
if XMax <= XMin then
|
if XMax <= XMin then
|
||||||
FCurItem.X := XMin
|
FCurItem.X := XMin
|
||||||
else begin
|
else begin
|
||||||
@ -845,6 +850,14 @@ begin
|
|||||||
Notify;
|
Notify;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TRandomChartSource.SetYNanPercent(AValue: TPercent);
|
||||||
|
begin
|
||||||
|
if FYNanPercent = AValue then exit;
|
||||||
|
FYNanPercent := AValue;
|
||||||
|
InvalidateCaches;
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TUserDefinedChartSource }
|
{ TUserDefinedChartSource }
|
||||||
|
|
||||||
procedure TUserDefinedChartSource.EndUpdate;
|
procedure TUserDefinedChartSource.EndUpdate;
|
||||||
|
Loading…
Reference in New Issue
Block a user