mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 04:59:20 +02:00
TAChart: Add ZeroLevel and UseZeroLevel properties to TAreaSeries, Update demo.
git-svn-id: trunk@27024 -
This commit is contained in:
parent
c0a6f3aa38
commit
3d00e0005f
@ -56,6 +56,7 @@ object Form1: TForm1
|
|||||||
AreaContourPen.Width = 2
|
AreaContourPen.Width = 2
|
||||||
AreaLinesPen.Color = clRed
|
AreaLinesPen.Color = clRed
|
||||||
Source = RandomChartSource1
|
Source = RandomChartSource1
|
||||||
|
UseZeroLevel = True
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
|
@ -131,13 +131,18 @@ type
|
|||||||
FAreaLinesPen: TPen;
|
FAreaLinesPen: TPen;
|
||||||
FInvertedStairs: Boolean;
|
FInvertedStairs: Boolean;
|
||||||
FStairs: Boolean;
|
FStairs: Boolean;
|
||||||
|
FUseZeroLevel: Boolean;
|
||||||
|
FZeroLevel: Double;
|
||||||
|
|
||||||
|
function IsZeroLevelStored: boolean;
|
||||||
procedure SetAreaBrush(AValue: TBrush);
|
procedure SetAreaBrush(AValue: TBrush);
|
||||||
procedure SetAreaContourPen(AValue: TPen);
|
procedure SetAreaContourPen(AValue: TPen);
|
||||||
procedure SetAreaLinesPen(AValue: TPen);
|
procedure SetAreaLinesPen(AValue: TPen);
|
||||||
procedure SetInvertedStairs(Value: Boolean);
|
procedure SetInvertedStairs(Value: Boolean);
|
||||||
procedure SetSeriesColor(AValue: TColor);
|
procedure SetSeriesColor(AValue: TColor);
|
||||||
procedure SetStairs(Value: Boolean);
|
procedure SetStairs(Value: Boolean);
|
||||||
|
procedure SetUseZeroLevel(AValue: Boolean);
|
||||||
|
procedure SetZeroLevel(AValue: Double);
|
||||||
protected
|
protected
|
||||||
function GetLabelDirection(AIndex: Integer): TLabelDirection; override;
|
function GetLabelDirection(AIndex: Integer): TLabelDirection; override;
|
||||||
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
||||||
@ -162,6 +167,10 @@ type
|
|||||||
property Source;
|
property Source;
|
||||||
property Stairs: Boolean read FStairs write SetStairs default false;
|
property Stairs: Boolean read FStairs write SetStairs default false;
|
||||||
property UseReticule;
|
property UseReticule;
|
||||||
|
property UseZeroLevel: Boolean
|
||||||
|
read FUseZeroLevel write SetUseZeroLevel default false;
|
||||||
|
property ZeroLevel: Double
|
||||||
|
read FZeroLevel write SetZeroLevel stored IsZeroLevelStored;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TSeriesPointerDrawEvent = procedure (
|
TSeriesPointerDrawEvent = procedure (
|
||||||
@ -1114,7 +1123,7 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
a, b: TDoublePoint;
|
a, b: TDoublePoint;
|
||||||
ext, ext2: TDoubleRect;
|
ext, ext2: TDoubleRect;
|
||||||
zeroLevel: Double;
|
z: Double;
|
||||||
begin
|
begin
|
||||||
if Count = 0 then exit;
|
if Count = 0 then exit;
|
||||||
|
|
||||||
@ -1129,13 +1138,15 @@ begin
|
|||||||
SetLength(pts, Length(FGraphPoints) * 2 + 2);
|
SetLength(pts, Length(FGraphPoints) * 2 + 2);
|
||||||
numPts := 0;
|
numPts := 0;
|
||||||
|
|
||||||
if IsRotated then
|
if UseZeroLevel then
|
||||||
zeroLevel := ext2.a.X
|
z := ZeroLevel
|
||||||
|
else if IsRotated then
|
||||||
|
z := ext2.a.X
|
||||||
else
|
else
|
||||||
zeroLevel := ext2.a.Y;
|
z := ext2.a.Y;
|
||||||
|
|
||||||
a := ProjToRect(FGraphPoints[0], ext2);
|
a := ProjToRect(FGraphPoints[0], ext2);
|
||||||
PushPoint(ProjToLine(a, zeroLevel));
|
PushPoint(ProjToLine(a, z));
|
||||||
PushPoint(a);
|
PushPoint(a);
|
||||||
for i := 0 to High(FGraphPoints) - 1 do begin
|
for i := 0 to High(FGraphPoints) - 1 do begin
|
||||||
a := FGraphPoints[i];
|
a := FGraphPoints[i];
|
||||||
@ -1153,7 +1164,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
a := ProjToRect(FGraphPoints[High(FGraphPoints)], ext2);
|
a := ProjToRect(FGraphPoints[High(FGraphPoints)], ext2);
|
||||||
PushPoint(a);
|
PushPoint(a);
|
||||||
PushPoint(ProjToLine(a, zeroLevel));
|
PushPoint(ProjToLine(a, z));
|
||||||
|
|
||||||
ACanvas.Brush.Assign(AreaBrush);
|
ACanvas.Brush.Assign(AreaBrush);
|
||||||
ACanvas.Pen.Assign(AreaContourPen);
|
ACanvas.Pen.Assign(AreaContourPen);
|
||||||
@ -1162,7 +1173,7 @@ begin
|
|||||||
ACanvas.Pen.Assign(AreaLinesPen);
|
ACanvas.Pen.Assign(AreaLinesPen);
|
||||||
for i := 1 to High(FGraphPoints) - 1 do begin
|
for i := 1 to High(FGraphPoints) - 1 do begin
|
||||||
a := ProjToRect(FGraphPoints[i], ext2);
|
a := ProjToRect(FGraphPoints[i], ext2);
|
||||||
b := ProjToLine(a, zeroLevel);
|
b := ProjToLine(a, z);
|
||||||
ACanvas.Line(ParentChart.GraphToImage(a), ParentChart.GraphToImage(b));
|
ACanvas.Line(ParentChart.GraphToImage(a), ParentChart.GraphToImage(b));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1187,6 +1198,11 @@ begin
|
|||||||
Result := FAreaBrush.Color;
|
Result := FAreaBrush.Color;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TAreaSeries.IsZeroLevelStored: boolean;
|
||||||
|
begin
|
||||||
|
Result := ZeroLevel <> 0.0;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TAreaSeries.SetAreaBrush(AValue: TBrush);
|
procedure TAreaSeries.SetAreaBrush(AValue: TBrush);
|
||||||
begin
|
begin
|
||||||
FAreaBrush.Assign(AValue);
|
FAreaBrush.Assign(AValue);
|
||||||
@ -1222,6 +1238,20 @@ begin
|
|||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TAreaSeries.SetUseZeroLevel(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FUseZeroLevel = AValue then exit;
|
||||||
|
FUseZeroLevel := AValue;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TAreaSeries.SetZeroLevel(AValue: Double);
|
||||||
|
begin
|
||||||
|
if FZeroLevel = AValue then exit;
|
||||||
|
FZeroLevel := AValue;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFuncSeries }
|
{ TFuncSeries }
|
||||||
|
|
||||||
constructor TFuncSeries.Create(AOwner: TComponent);
|
constructor TFuncSeries.Create(AOwner: TComponent);
|
||||||
|
Loading…
Reference in New Issue
Block a user