mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 09:49:22 +02:00
TAChart: Add new property RandomColors to TRandomChartSource.
This commit is contained in:
parent
5b7387ddd5
commit
34f156c0b9
@ -149,6 +149,7 @@ type
|
|||||||
TRandomChartSource = class(TCustomChartSource)
|
TRandomChartSource = class(TCustomChartSource)
|
||||||
strict private
|
strict private
|
||||||
FPointsNumber: Integer;
|
FPointsNumber: Integer;
|
||||||
|
FRandomColors: Boolean;
|
||||||
FRandomX: Boolean;
|
FRandomX: Boolean;
|
||||||
FRandSeed: Integer;
|
FRandSeed: Integer;
|
||||||
FXMax: Double;
|
FXMax: Double;
|
||||||
@ -163,6 +164,7 @@ type
|
|||||||
|
|
||||||
procedure Reset;
|
procedure Reset;
|
||||||
procedure SetPointsNumber(AValue: Integer);
|
procedure SetPointsNumber(AValue: Integer);
|
||||||
|
procedure SetRandomColors(AValue: Boolean);
|
||||||
procedure SetRandomX(AValue: Boolean);
|
procedure SetRandomX(AValue: Boolean);
|
||||||
procedure SetRandSeed(AValue: Integer);
|
procedure SetRandSeed(AValue: Integer);
|
||||||
procedure SetXMax(const AValue: Double);
|
procedure SetXMax(const AValue: Double);
|
||||||
@ -182,8 +184,8 @@ type
|
|||||||
public
|
public
|
||||||
function IsSorted: Boolean; override;
|
function IsSorted: Boolean; override;
|
||||||
published
|
published
|
||||||
property PointsNumber: Integer
|
property PointsNumber: Integer read FPointsNumber write SetPointsNumber default 0;
|
||||||
read FPointsNumber write SetPointsNumber default 0;
|
property RandomColors: Boolean read FRandomColors write SetRandomColors default false;
|
||||||
property RandomX: Boolean read FRandomX write SetRandomX default false;
|
property RandomX: Boolean read FRandomX write SetRandomX default false;
|
||||||
property RandSeed: Integer read FRandSeed write SetRandSeed;
|
property RandSeed: Integer read FRandSeed write SetRandSeed;
|
||||||
property XCount;
|
property XCount;
|
||||||
@ -1262,6 +1264,11 @@ end;
|
|||||||
|
|
||||||
function TRandomChartSource.GetItem(AIndex: Integer): PChartDataItem;
|
function TRandomChartSource.GetItem(AIndex: Integer): PChartDataItem;
|
||||||
|
|
||||||
|
function GetRandomColor: TChartColor;
|
||||||
|
begin
|
||||||
|
Result := FRNG.Get and $00FFFFFF;
|
||||||
|
end;
|
||||||
|
|
||||||
function GetRandomX: Double;
|
function GetRandomX: Double;
|
||||||
begin
|
begin
|
||||||
Result := FRNG.Get / High(LongWord) * (XMax - XMin) + XMin;
|
Result := FRNG.Get / High(LongWord) * (XMax - XMin) + XMin;
|
||||||
@ -1329,6 +1336,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
if FRandomColors then
|
||||||
|
FCurItem.Color := GetRandomColor;;
|
||||||
end;
|
end;
|
||||||
Result := @FCurItem;
|
Result := @FCurItem;
|
||||||
end;
|
end;
|
||||||
@ -1352,6 +1361,13 @@ begin
|
|||||||
Reset;
|
Reset;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TRandomChartSource.SetRandomColors(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FRandomColors = AValue then exit;
|
||||||
|
FRandomColors := AValue;
|
||||||
|
Reset;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TRandomChartSource.SetRandomX(AValue: Boolean);
|
procedure TRandomChartSource.SetRandomX(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if FRandomX = AValue then exit;
|
if FRandomX = AValue then exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user