mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 17:19:23 +02:00
TAChart: Add TOpenHighLowCloseSeries.DownLinePen property
git-svn-id: trunk@39378 -
This commit is contained in:
parent
a7744fadc5
commit
ab8e758c9b
@ -113,16 +113,21 @@ type
|
|||||||
property Source;
|
property Source;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TOpenHighLowCloseSeries }
|
TOHLCDownPen = class(TPen)
|
||||||
|
published
|
||||||
|
property Color default clTAColor;
|
||||||
|
end;
|
||||||
|
|
||||||
TOpenHighLowCloseSeries = class(TBasicPointSeries)
|
TOpenHighLowCloseSeries = class(TBasicPointSeries)
|
||||||
private
|
private
|
||||||
|
FDownLinePen: TOHLCDownPen;
|
||||||
FLinePen: TPen;
|
FLinePen: TPen;
|
||||||
FTickWidth: Cardinal;
|
FTickWidth: Cardinal;
|
||||||
FYIndexClose: Cardinal;
|
FYIndexClose: Cardinal;
|
||||||
FYIndexHigh: Cardinal;
|
FYIndexHigh: Cardinal;
|
||||||
FYIndexLow: Cardinal;
|
FYIndexLow: Cardinal;
|
||||||
FYIndexOpen: Cardinal;
|
FYIndexOpen: Cardinal;
|
||||||
|
procedure SetDownLinePen(AValue: TOHLCDownPen);
|
||||||
procedure SetLinePen(AValue: TPen);
|
procedure SetLinePen(AValue: TPen);
|
||||||
procedure SetTickWidth(AValue: Cardinal);
|
procedure SetTickWidth(AValue: Cardinal);
|
||||||
procedure SetYIndexClose(AValue: Cardinal);
|
procedure SetYIndexClose(AValue: Cardinal);
|
||||||
@ -135,11 +140,12 @@ type
|
|||||||
public
|
public
|
||||||
procedure Assign(ASource: TPersistent); override;
|
procedure Assign(ASource: TPersistent); override;
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
procedure Draw(ADrawer: IChartDrawer); override;
|
procedure Draw(ADrawer: IChartDrawer); override;
|
||||||
function Extent: TDoubleRect; override;
|
function Extent: TDoubleRect; override;
|
||||||
published
|
published
|
||||||
|
property DownLinePen: TOHLCDownPen read FDownLinePen write SetDownLinePen;
|
||||||
property LinePen: TPen read FLinePen write SetLinePen;
|
property LinePen: TPen read FLinePen write SetLinePen;
|
||||||
property TickWidth: Cardinal
|
property TickWidth: Cardinal
|
||||||
read FTickWidth write SetTickWidth default DEF_OHLC_TICK_WIDTH;
|
read FTickWidth write SetTickWidth default DEF_OHLC_TICK_WIDTH;
|
||||||
@ -483,6 +489,7 @@ procedure TOpenHighLowCloseSeries.Assign(ASource: TPersistent);
|
|||||||
begin
|
begin
|
||||||
if ASource is TOpenHighLowCloseSeries then
|
if ASource is TOpenHighLowCloseSeries then
|
||||||
with TOpenHighLowCloseSeries(ASource) do begin
|
with TOpenHighLowCloseSeries(ASource) do begin
|
||||||
|
Self.DownLinePen := FDownLinePen;
|
||||||
Self.LinePen := FLinePen;
|
Self.LinePen := FLinePen;
|
||||||
Self.FTickWidth := FTickWidth;
|
Self.FTickWidth := FTickWidth;
|
||||||
Self.FYIndexClose := FYIndexClose;
|
Self.FYIndexClose := FYIndexClose;
|
||||||
@ -496,6 +503,9 @@ end;
|
|||||||
constructor TOpenHighLowCloseSeries.Create(AOwner: TComponent);
|
constructor TOpenHighLowCloseSeries.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
|
FDownLinePen := TOHLCDownPen.Create;
|
||||||
|
FDownLinePen.Color := clTAColor;
|
||||||
|
FDownLinePen.OnChange := @StyleChanged;
|
||||||
FLinePen := TPen.Create;
|
FLinePen := TPen.Create;
|
||||||
FLinePen.OnChange := @StyleChanged;
|
FLinePen.OnChange := @StyleChanged;
|
||||||
FTickWidth := DEF_OHLC_TICK_WIDTH;
|
FTickWidth := DEF_OHLC_TICK_WIDTH;
|
||||||
@ -507,8 +517,9 @@ end;
|
|||||||
|
|
||||||
destructor TOpenHighLowCloseSeries.Destroy;
|
destructor TOpenHighLowCloseSeries.Destroy;
|
||||||
begin
|
begin
|
||||||
|
FreeAndNil(FDownLinePen);
|
||||||
FreeAndNil(FLinePen);
|
FreeAndNil(FLinePen);
|
||||||
inherited Destroy;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TOpenHighLowCloseSeries.Draw(ADrawer: IChartDrawer);
|
procedure TOpenHighLowCloseSeries.Draw(ADrawer: IChartDrawer);
|
||||||
@ -556,7 +567,10 @@ begin
|
|||||||
yclose := GetGraphPointYIndex(i, YIndexClose);
|
yclose := GetGraphPointYIndex(i, YIndexClose);
|
||||||
tw := GetXRange(x, i) * PERCENT * TickWidth;
|
tw := GetXRange(x, i) * PERCENT * TickWidth;
|
||||||
|
|
||||||
ADrawer.Pen := LinePen;
|
if (DownLinePen.Color = clTAColor) or (yopen <= yclose) then
|
||||||
|
ADrawer.Pen := LinePen
|
||||||
|
else
|
||||||
|
ADrawer.Pen := DownLinePen;
|
||||||
DoLine(x, yhigh, x, ylow);
|
DoLine(x, yhigh, x, ylow);
|
||||||
DoLine(x - tw, yopen, x, yopen);
|
DoLine(x - tw, yopen, x, yopen);
|
||||||
DoLine(x, yclose, x + tw, yclose);
|
DoLine(x, yclose, x + tw, yclose);
|
||||||
@ -578,10 +592,17 @@ begin
|
|||||||
Result := LinePen.Color;
|
Result := LinePen.Color;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TOpenHighLowCloseSeries.SetDownLinePen(AValue: TOHLCDownPen);
|
||||||
|
begin
|
||||||
|
if FDownLinePen = AValue then exit;
|
||||||
|
FDownLinePen.Assign(AValue);
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TOpenHighLowCloseSeries.SetLinePen(AValue: TPen);
|
procedure TOpenHighLowCloseSeries.SetLinePen(AValue: TPen);
|
||||||
begin
|
begin
|
||||||
if FLinePen = AValue then exit;
|
if FLinePen = AValue then exit;
|
||||||
FLinePen := AValue;
|
FLinePen.Assign(AValue);
|
||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user