Code Formatting
This commit is contained in:
@@ -23,7 +23,8 @@ type
|
|||||||
TCandleStyle = (csCandleStick, csHiLoBar);
|
TCandleStyle = (csCandleStick, csHiLoBar);
|
||||||
|
|
||||||
TMycChart = class(TStyledControl)
|
TMycChart = class(TStyledControl)
|
||||||
public type
|
public
|
||||||
|
type
|
||||||
TSeries = class abstract(TObject)
|
TSeries = class abstract(TObject)
|
||||||
private
|
private
|
||||||
FOwner: TMycChart;
|
FOwner: TMycChart;
|
||||||
@@ -33,7 +34,11 @@ type
|
|||||||
function GetValueRange(StartIndex, Count: Int64; out Min, Max: Double): Boolean; virtual; abstract;
|
function GetValueRange(StartIndex, Count: Int64; out Min, Max: Double): Boolean; virtual; abstract;
|
||||||
function Update: Boolean; virtual; abstract;
|
function Update: Boolean; virtual; abstract;
|
||||||
// The signature is changed to support viewport painting
|
// The signature is changed to support viewport painting
|
||||||
procedure Paint(const ACanvas: TCanvas; StartIndex, Count: Int64; const AXForm, AYForm: TFunc<Double, Single>); virtual; abstract;
|
procedure Paint(
|
||||||
|
const ACanvas: TCanvas;
|
||||||
|
StartIndex, Count: Int64;
|
||||||
|
const AXForm, AYForm: TFunc<Double, Single>
|
||||||
|
); virtual; abstract;
|
||||||
property MainSeries: TSeries read GetMainSeries;
|
property MainSeries: TSeries read GetMainSeries;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TMycChart);
|
constructor Create(AOwner: TMycChart);
|
||||||
@@ -51,7 +56,8 @@ private
|
|||||||
FDragStartPoint: TPointF;
|
FDragStartPoint: TPointF;
|
||||||
FJumpButtonRect: TRectF;
|
FJumpButtonRect: TRectF;
|
||||||
FJumpButtonHot: Boolean;
|
FJumpButtonHot: Boolean;
|
||||||
FJumpButtonPressed: Boolean; protected
|
FJumpButtonPressed: Boolean;
|
||||||
|
protected
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure DoIdle;
|
procedure DoIdle;
|
||||||
procedure MouseWheel(Shift: TShiftState; WheelDelta: Integer; var Handled: Boolean); override;
|
procedure MouseWheel(Shift: TShiftState; WheelDelta: Integer; var Handled: Boolean); override;
|
||||||
@@ -362,7 +368,6 @@ begin
|
|||||||
// The formula for that is FViewStartIndex := FViewStartIndex + indexDelta; -> StartIndex + (negative) = decrease.
|
// The formula for that is FViewStartIndex := FViewStartIndex + indexDelta; -> StartIndex + (negative) = decrease.
|
||||||
FViewStartIndex := FViewStartIndex + indexDelta;
|
FViewStartIndex := FViewStartIndex + indexDelta;
|
||||||
|
|
||||||
|
|
||||||
// Clamp values
|
// Clamp values
|
||||||
mainSeries := FSeriesList[0];
|
mainSeries := FSeriesList[0];
|
||||||
maxIndex := 0;
|
maxIndex := 0;
|
||||||
@@ -375,8 +380,10 @@ begin
|
|||||||
maxIndex := 0;
|
maxIndex := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (FViewStartIndex < 0) then FViewStartIndex := 0;
|
if (FViewStartIndex < 0) then
|
||||||
if (FViewStartIndex > maxIndex) then FViewStartIndex := maxIndex;
|
FViewStartIndex := 0;
|
||||||
|
if (FViewStartIndex > maxIndex) then
|
||||||
|
FViewStartIndex := maxIndex;
|
||||||
|
|
||||||
FDragStartPoint := TPointF.Create(X, Y);
|
FDragStartPoint := TPointF.Create(X, Y);
|
||||||
Repaint;
|
Repaint;
|
||||||
@@ -417,9 +424,12 @@ begin
|
|||||||
newViewCount := Round(FViewCount * zoomFactor);
|
newViewCount := Round(FViewCount * zoomFactor);
|
||||||
|
|
||||||
// Clamp zoom level
|
// Clamp zoom level
|
||||||
if (newViewCount < 10) then newViewCount := 10;
|
if (newViewCount < 10) then
|
||||||
if (newViewCount > mainSeries.Count) then newViewCount := mainSeries.Count;
|
newViewCount := 10;
|
||||||
if (newViewCount = FViewCount) then exit;
|
if (newViewCount > mainSeries.Count) then
|
||||||
|
newViewCount := mainSeries.Count;
|
||||||
|
if (newViewCount = FViewCount) then
|
||||||
|
exit;
|
||||||
|
|
||||||
// Adjust start index to keep anchor point stable
|
// Adjust start index to keep anchor point stable
|
||||||
if (FViewCount > 0) then
|
if (FViewCount > 0) then
|
||||||
@@ -431,7 +441,8 @@ begin
|
|||||||
FViewCount := newViewCount;
|
FViewCount := newViewCount;
|
||||||
|
|
||||||
// Clamp start index
|
// Clamp start index
|
||||||
if (FViewStartIndex < 0) then FViewStartIndex := 0;
|
if (FViewStartIndex < 0) then
|
||||||
|
FViewStartIndex := 0;
|
||||||
if (FViewStartIndex + FViewCount > mainSeries.Count) then
|
if (FViewStartIndex + FViewCount > mainSeries.Count) then
|
||||||
begin
|
begin
|
||||||
FViewStartIndex := mainSeries.Count - FViewCount;
|
FViewStartIndex := mainSeries.Count - FViewCount;
|
||||||
@@ -494,7 +505,8 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
// Transform maps an index from the viewport to a screen coordinate
|
// Transform maps an index from the viewport to a screen coordinate
|
||||||
xTransform := function(index: Double): Single
|
xTransform :=
|
||||||
|
function(index: Double): Single
|
||||||
begin
|
begin
|
||||||
if (FViewCount <= 1) then
|
if (FViewCount <= 1) then
|
||||||
begin
|
begin
|
||||||
@@ -505,10 +517,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
yTransform :=
|
yTransform :=
|
||||||
function(value: Double): Single
|
function(value: Double): Single begin Result := rect.Top + (1 - (value - globalMin) / (globalMax - globalMin)) * rect.Height; end;
|
||||||
begin
|
|
||||||
Result := rect.Top + (1 - (value - globalMin) / (globalMax - globalMin)) * rect.Height;
|
|
||||||
end;
|
|
||||||
|
|
||||||
for series in FSeriesList do
|
for series in FSeriesList do
|
||||||
begin
|
begin
|
||||||
|
|||||||
Reference in New Issue
Block a user