diff --git a/components/tachart/tacustomsource.pas b/components/tachart/tacustomsource.pas index 258b486678..bc72d4c30e 100644 --- a/components/tachart/tacustomsource.pas +++ b/components/tachart/tacustomsource.pas @@ -93,11 +93,11 @@ type YList: TDoubleDynArray; function GetX(AIndex: Integer): Double; function GetY(AIndex: Integer): Double; - procedure SetX(AIndex: Integer; AValue: Double); - procedure SetX(AValue: Double); - procedure SetY(AIndex: Integer; AValue: Double); - procedure SetY(AValue: Double); - procedure MultiplyY(ACoeff: Double); + procedure SetX(AIndex: Integer; const AValue: Double); + procedure SetX(const AValue: Double); + procedure SetY(AIndex: Integer; const AValue: Double); + procedure SetY(const AValue: Double); + procedure MultiplyY(const ACoeff: Double); function Point: TDoublePoint; inline; end; PChartDataItem = ^TChartDataItem; @@ -165,7 +165,7 @@ type function IsErrorBarValueStored(AIndex: Integer): Boolean; procedure SetKind(AValue: TChartErrorBarKind); procedure SetIndex(AIndex, AValue: Integer); - procedure SetValue(AIndex: Integer; AValue: Double); + procedure SetValue(AIndex: Integer; const AValue: Double); public constructor Create; procedure Assign(ASource: TPersistent); override; @@ -245,7 +245,7 @@ type function FormatItem( const AFormat: String; AIndex, AYIndex: Integer): String; inline; function FormatItemXYText( - const AFormat: String; AX, AY: Double; AText: String): String; + const AFormat: String; const AX, AY: Double; const AText: String): String; function GetEnumerator: TCustomChartSourceEnumerator; function GetXErrorBarLimits(APointIndex: Integer; out AUpperLimit, ALowerLimit: Double): Boolean; @@ -383,7 +383,7 @@ end; procedure TValuesInRangeParams.RoundToImage(var AValue: Double); - function A2I(AX: Double): Integer; inline; + function A2I(const AX: Double): Integer; inline; begin Result := FGraphToImage(FAxisToGraph(AX)); end; @@ -535,7 +535,7 @@ begin Result := YList[AIndex - 1]; end; -procedure TChartDataItem.MultiplyY(ACoeff: Double); +procedure TChartDataItem.MultiplyY(const ACoeff: Double); var i: Integer; begin @@ -550,7 +550,7 @@ begin Result.Y := Y; end; -procedure TChartDataItem.SetX(AValue: Double); +procedure TChartDataItem.SetX(const AValue: Double); var i: Integer; begin @@ -559,7 +559,7 @@ begin XList[i] := AValue; end; -procedure TChartDataItem.SetX(AIndex: Integer; AValue: Double); +procedure TChartDataItem.SetX(AIndex: Integer; const AValue: Double); begin if AIndex = 0 then X := AValue @@ -567,7 +567,7 @@ begin XList[AIndex - 1] := AValue; end; -procedure TChartDataItem.SetY(AValue: Double); +procedure TChartDataItem.SetY(const AValue: Double); var i: Integer; begin @@ -576,7 +576,7 @@ begin YList[i] := AValue; end; -procedure TChartDataItem.SetY(AIndex: Integer; AValue: Double); +procedure TChartDataItem.SetY(AIndex: Integer; const AValue: Double); begin if AIndex = 0 then Y := AValue @@ -818,7 +818,7 @@ begin Changed; end; -procedure TChartErrorBarData.SetValue(AIndex: Integer; AValue: Double); +procedure TChartErrorBarData.SetValue(AIndex: Integer; const AValue: Double); begin if FValue[AIndex] = AValue then exit; FValue[AIndex] := AValue; @@ -1080,7 +1080,7 @@ end; procedure TCustomChartSource.FindBounds( AXMin, AXMax: Double; out ALB, AUB: Integer); - function FindLB(X: Double; L, R: Integer): Integer; + function FindLB(const X: Double; L, R: Integer): Integer; begin while L <= R do begin Result := (R - L) div 2 + L; @@ -1092,7 +1092,7 @@ procedure TCustomChartSource.FindBounds( Result := L; end; - function FindUB(X: Double; L, R: Integer): Integer; + function FindUB(const X: Double; L, R: Integer): Integer; begin while L <= R do begin Result := (R - L) div 2 + L; @@ -1138,11 +1138,11 @@ function TCustomChartSource.FormatItem( const AFormat: String; AIndex, AYIndex: Integer): String; begin with Item[AIndex]^ do - Result := FormatItemXYText(AFormat, IfThen(XCount > 0, X, double(AIndex)), GetY(AYIndex), Text); + Result := FormatItemXYText(AFormat, IfThen(XCount > 0, X, Double(AIndex)), GetY(AYIndex), Text); end; function TCustomChartSource.FormatItemXYText( - const AFormat: String; AX, AY: Double; AText: String): String; + const AFormat: String; const AX, AY: Double; const AText: String): String; const TO_PERCENT = 100; var @@ -1437,7 +1437,7 @@ procedure TCustomChartSource.ValuesInRange( var prevImagePos: Integer = MaxInt; - function IsTooClose(AValue: Double): Boolean; + function IsTooClose(const AValue: Double): Boolean; var imagePos: Integer; begin diff --git a/components/tachart/tasources.pas b/components/tachart/tasources.pas index c4cf2d5cfa..1fe299254f 100644 --- a/components/tachart/tasources.pas +++ b/components/tachart/tasources.pas @@ -28,11 +28,11 @@ type FXCountMin: Cardinal; FYCountMin: Cardinal; procedure AddAt( - APos: Integer; AX, AY: Double; const ALabel: String; AColor: TChartColor); + APos: Integer; const AX, AY: Double; const ALabel: String; AColor: TChartColor); procedure ClearCaches; function NewItem: PChartDataItem; - procedure SetDataPoints(AValue: TStrings); - procedure UpdateCachesAfterAdd(AX, AY: Double); + procedure SetDataPoints(const AValue: TStrings); + procedure UpdateCachesAfterAdd(const AX, AY: Double); protected procedure Loaded; override; procedure SetXCount(AValue: Cardinal); override; @@ -47,22 +47,22 @@ type destructor Destroy; override; public function Add( - AX, AY: Double; const ALabel: String = ''; - AColor: TChartColor = clTAColor): Integer; - function AddXListYList(const AX, AY: array of Double; ALabel: String = ''; - AColor: TChartColor = clTAColor): Integer; + const AX, AY: Double; const ALabel: String = ''; + const AColor: TChartColor = clTAColor): Integer; + function AddXListYList(const AX, AY: array of Double; const ALabel: String = ''; + const AColor: TChartColor = clTAColor): Integer; function AddXYList( - AX: Double; const AY: array of Double; const ALabel: String = ''; - AColor: TChartColor = clTAColor): Integer; + const AX: Double; const AY: array of Double; const ALabel: String = ''; + const AColor: TChartColor = clTAColor): Integer; procedure Clear; procedure CopyFrom(ASource: TCustomChartSource); procedure Delete(AIndex: Integer); procedure SetColor(AIndex: Integer; AColor: TChartColor); - procedure SetText(AIndex: Integer; AValue: String); - function SetXValue(AIndex: Integer; AValue: Double): Integer; + procedure SetText(AIndex: Integer; const AValue: String); procedure SetXList(AIndex: Integer; const AXList: array of Double); + function SetXValue(AIndex: Integer; const AValue: Double): Integer; procedure SetYList(AIndex: Integer; const AYList: array of Double); - procedure SetYValue(AIndex: Integer; AValue: Double); + procedure SetYValue(AIndex: Integer; const AValue: Double); published property DataPoints: TStrings read FDataPoints write SetDataPoints; property XCount; @@ -114,10 +114,10 @@ type procedure SetPointsNumber(AValue: Integer); procedure SetRandomX(AValue: Boolean); procedure SetRandSeed(AValue: Integer); - procedure SetXMax(AValue: Double); - procedure SetXMin(AValue: Double); - procedure SetYMax(AValue: Double); - procedure SetYMin(AValue: Double); + procedure SetXMax(const AValue: Double); + procedure SetXMin(const AValue: Double); + procedure SetYMax(const AValue: Double); + procedure SetYMin(const AValue: Double); procedure SetYNanPercent(AValue: TPercent); protected procedure ChangeErrorBars(Sender: TObject); override; @@ -258,7 +258,7 @@ type strict private FSource: TListChartSource; FLoadingCache: TStringList; - procedure Parse(AString: String; ADataItem: PChartDataItem); + procedure Parse(const AString: String; ADataItem: PChartDataItem); private procedure LoadingFinished; protected @@ -313,7 +313,7 @@ end; function TListChartSourceStrings.Get(Index: Integer): String; - function NumberStr(AValue: Double): String; + function NumberStr(const AValue: Double): String; begin if IsNaN(AValue) then Result := '|' @@ -382,7 +382,7 @@ begin end; procedure TListChartSourceStrings.Parse( - AString: String; ADataItem: PChartDataItem); + const AString: String; ADataItem: PChartDataItem); var p: Integer = 0; parts: TStrings; @@ -487,7 +487,8 @@ end; { TListChartSource } function TListChartSource.Add( - AX, AY: Double; const ALabel: String; AColor: TChartColor): Integer; + const AX, AY: Double; const ALabel: String = ''; + const AColor: TChartColor = clTAColor): Integer; begin Result := FData.Count; if IsSortedByXAsc then @@ -502,7 +503,7 @@ begin end; procedure TListChartSource.AddAt( - APos: Integer; AX, AY: Double; const ALabel: String; AColor: TChartColor); + APos: Integer; const AX, AY: Double; const ALabel: String; AColor: TChartColor); var pcd: PChartDataItem; begin @@ -516,7 +517,7 @@ begin end; function TListChartSource.AddXListYList(const AX, AY: array of Double; - ALabel: String = ''; AColor: TChartColor = clTAColor): Integer; + const ALabel: String = ''; const AColor: TChartColor = clTAColor): Integer; begin if Length(AX) = 0 then raise EXListEmptyError.Create('AddXListYList: XList is empty'); @@ -539,8 +540,8 @@ begin end; function TListChartSource.AddXYList( - AX: Double; const AY: array of Double; - const ALabel: String; AColor: TChartColor): Integer; + const AX: Double; const AY: array of Double; + const ALabel: String = ''; const AColor: TChartColor = clTAColor): Integer; begin if Length(AY) = 0 then raise EYListEmptyError.Create('AddXYList: Y List is empty'); @@ -688,7 +689,7 @@ begin Notify; end; -procedure TListChartSource.SetDataPoints(AValue: TStrings); +procedure TListChartSource.SetDataPoints(const AValue: TStrings); begin if FDataPoints = AValue then exit; BeginUpdate; @@ -700,7 +701,7 @@ begin end; end; -procedure TListChartSource.SetText(AIndex: Integer; AValue: String); +procedure TListChartSource.SetText(AIndex: Integer; const AValue: String); begin with Item[AIndex]^ do begin if Text = AValue then exit; @@ -736,7 +737,7 @@ begin Notify; end; -function TListChartSource.SetXValue(AIndex: Integer; AValue: Double): Integer; +function TListChartSource.SetXValue(AIndex: Integer; const AValue: Double): Integer; var oldX: Double; @@ -807,7 +808,7 @@ begin Notify; end; -procedure TListChartSource.SetYValue(AIndex: Integer; AValue: Double); +procedure TListChartSource.SetYValue(AIndex: Integer; const AValue: Double); var oldY: Double; @@ -838,7 +839,7 @@ begin Notify; end; -procedure TListChartSource.UpdateCachesAfterAdd(AX, AY: Double); +procedure TListChartSource.UpdateCachesAfterAdd(const AX, AY: Double); begin if IsUpdating then exit; // Optimization if FBasicExtentIsValid then begin @@ -1044,14 +1045,14 @@ begin Reset; end; -procedure TRandomChartSource.SetXMax(AValue: Double); +procedure TRandomChartSource.SetXMax(const AValue: Double); begin if FXMax = AValue then exit; FXMax := AValue; Reset; end; -procedure TRandomChartSource.SetXMin(AValue: Double); +procedure TRandomChartSource.SetXMin(const AValue: Double); begin if FXMin = AValue then exit; FXMin := AValue; @@ -1065,7 +1066,7 @@ begin Reset; end; -procedure TRandomChartSource.SetYMax(AValue: Double); +procedure TRandomChartSource.SetYMax(const AValue: Double); begin if FYMax = AValue then exit; FYMax := AValue; @@ -1073,7 +1074,7 @@ begin Notify; end; -procedure TRandomChartSource.SetYMin(AValue: Double); +procedure TRandomChartSource.SetYMin(const AValue: Double); begin if FYMin = AValue then exit; FYMin := AValue;