mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 16:16:05 +02:00
TAChart: Add MarkPositions property to point-based series
git-svn-id: trunk@30578 -
This commit is contained in:
parent
c96a1114c1
commit
4f051e1e6d
@ -182,10 +182,15 @@ type
|
|||||||
|
|
||||||
TLabelDirection = (ldLeft, ldTop, ldRight, ldBottom);
|
TLabelDirection = (ldLeft, ldTop, ldRight, ldBottom);
|
||||||
|
|
||||||
|
TLinearMarkPositions = (lmpOutside, lmpPositive, lmpNegative, lmpInside);
|
||||||
|
|
||||||
{ TBasicPointSeries }
|
{ TBasicPointSeries }
|
||||||
|
|
||||||
TBasicPointSeries = class(TChartSeries)
|
TBasicPointSeries = class(TChartSeries)
|
||||||
private
|
private
|
||||||
|
FMarkPositions: TLinearMarkPositions;
|
||||||
|
function GetLabelDirection(AIndex: Integer): TLabelDirection;
|
||||||
|
procedure SetMarkPositions(AValue: TLinearMarkPositions);
|
||||||
procedure SetUseReticule(AValue: Boolean);
|
procedure SetUseReticule(AValue: Boolean);
|
||||||
|
|
||||||
protected
|
protected
|
||||||
@ -196,9 +201,9 @@ type
|
|||||||
FUseReticule: Boolean;
|
FUseReticule: Boolean;
|
||||||
|
|
||||||
procedure DrawLabels(ADrawer: IChartDrawer);
|
procedure DrawLabels(ADrawer: IChartDrawer);
|
||||||
function GetLabelDirection(AIndex: Integer): TLabelDirection; virtual;
|
|
||||||
procedure GetLegendItemsRect(AItems: TChartLegendItems; ABrush: TBrush);
|
procedure GetLegendItemsRect(AItems: TChartLegendItems; ABrush: TBrush);
|
||||||
function GetXRange(AX: Double; AIndex: Integer): Double;
|
function GetXRange(AX: Double; AIndex: Integer): Double;
|
||||||
|
function GetZeroLevel: Double; virtual;
|
||||||
procedure PrepareGraphPoints(
|
procedure PrepareGraphPoints(
|
||||||
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
||||||
procedure UpdateGraphPoints(AIndex: Integer);
|
procedure UpdateGraphPoints(AIndex: Integer);
|
||||||
@ -212,6 +217,8 @@ type
|
|||||||
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
||||||
override;
|
override;
|
||||||
procedure MovePoint(var AIndex: Integer; const ANewPos: TPoint); override;
|
procedure MovePoint(var AIndex: Integer; const ANewPos: TPoint); override;
|
||||||
|
property MarkPositions: TLinearMarkPositions
|
||||||
|
read FMarkPositions write SetMarkPositions default lmpOutside;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -775,8 +782,16 @@ function TBasicPointSeries.GetLabelDirection(AIndex: Integer): TLabelDirection;
|
|||||||
const
|
const
|
||||||
DIR: array [Boolean, Boolean] of TLabelDirection =
|
DIR: array [Boolean, Boolean] of TLabelDirection =
|
||||||
((ldTop, ldBottom), (ldRight, ldLeft));
|
((ldTop, ldBottom), (ldRight, ldLeft));
|
||||||
|
var
|
||||||
|
isNeg: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := DIR[IsRotated, GetGraphPointY(AIndex) < 0];
|
case MarkPositions of
|
||||||
|
lmpOutside: isNeg := GetGraphPointY(AIndex) < GetZeroLevel;
|
||||||
|
lmpPositive: isNeg := false;
|
||||||
|
lmpNegative: isNeg := true;
|
||||||
|
lmpInside: isNeg := GetGraphPointY(AIndex) >= GetZeroLevel;
|
||||||
|
end;
|
||||||
|
Result := DIR[IsRotated, isNeg];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBasicPointSeries.GetLegendItemsRect(
|
procedure TBasicPointSeries.GetLegendItemsRect(
|
||||||
@ -834,6 +849,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBasicPointSeries.GetZeroLevel: Double;
|
||||||
|
begin
|
||||||
|
Result := 0.0;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBasicPointSeries.MovePoint(
|
procedure TBasicPointSeries.MovePoint(
|
||||||
var AIndex: Integer; const ANewPos: TPoint);
|
var AIndex: Integer; const ANewPos: TPoint);
|
||||||
var
|
var
|
||||||
@ -879,6 +899,13 @@ begin
|
|||||||
FGraphPoints[i - FLoBound] := GetGraphPoint(i);
|
FGraphPoints[i - FLoBound] := GetGraphPoint(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBasicPointSeries.SetMarkPositions(AValue: TLinearMarkPositions);
|
||||||
|
begin
|
||||||
|
if FMarkPositions = AValue then exit;
|
||||||
|
FMarkPositions := AValue;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBasicPointSeries.SetUseReticule(AValue: Boolean);
|
procedure TBasicPointSeries.SetUseReticule(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if FUseReticule = AValue then exit;
|
if FUseReticule = AValue then exit;
|
||||||
|
@ -92,6 +92,7 @@ type
|
|||||||
property BarWidthStyle: TBarWidthStyle
|
property BarWidthStyle: TBarWidthStyle
|
||||||
read FBarWidthStyle write SetBarWidthStyle default bwPercent;
|
read FBarWidthStyle write SetBarWidthStyle default bwPercent;
|
||||||
property Depth;
|
property Depth;
|
||||||
|
property MarkPositions;
|
||||||
property SeriesColor: TColor
|
property SeriesColor: TColor
|
||||||
read GetSeriesColor write SetSeriesColor stored false default clRed;
|
read GetSeriesColor write SetSeriesColor stored false default clRed;
|
||||||
property Source;
|
property Source;
|
||||||
@ -138,9 +139,9 @@ type
|
|||||||
procedure SetUseZeroLevel(AValue: Boolean);
|
procedure SetUseZeroLevel(AValue: Boolean);
|
||||||
procedure SetZeroLevel(AValue: Double);
|
procedure SetZeroLevel(AValue: Double);
|
||||||
protected
|
protected
|
||||||
function GetLabelDirection(AIndex: Integer): TLabelDirection; override;
|
|
||||||
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
||||||
function GetSeriesColor: TColor; override;
|
function GetSeriesColor: TColor; override;
|
||||||
|
function GetZeroLevel: Double; override;
|
||||||
public
|
public
|
||||||
procedure Assign(ASource: TPersistent); override;
|
procedure Assign(ASource: TPersistent); override;
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
@ -158,6 +159,7 @@ type
|
|||||||
property ConnectType: TConnectType
|
property ConnectType: TConnectType
|
||||||
read FConnectType write SetConnectType default ctLine;
|
read FConnectType write SetConnectType default ctLine;
|
||||||
property Depth;
|
property Depth;
|
||||||
|
property MarkPositions;
|
||||||
property SeriesColor: TColor
|
property SeriesColor: TColor
|
||||||
read GetSeriesColor write SetSeriesColor stored false default clWhite;
|
read GetSeriesColor write SetSeriesColor stored false default clWhite;
|
||||||
property Source;
|
property Source;
|
||||||
@ -213,6 +215,7 @@ type
|
|||||||
property LinePen: TPen read FLinePen write SetLinePen;
|
property LinePen: TPen read FLinePen write SetLinePen;
|
||||||
property LineType: TLineType
|
property LineType: TLineType
|
||||||
read FLineType write SetLineType default ltFromPrevious;
|
read FLineType write SetLineType default ltFromPrevious;
|
||||||
|
property MarkPositions;
|
||||||
property OnDrawPointer: TSeriesPointerDrawEvent
|
property OnDrawPointer: TSeriesPointerDrawEvent
|
||||||
read FOnDrawPointer write FOnDrawPointer;
|
read FOnDrawPointer write FOnDrawPointer;
|
||||||
property Pointer: TSeriesPointer read FPointer write SetPointer;
|
property Pointer: TSeriesPointer read FPointer write SetPointer;
|
||||||
@ -1098,15 +1101,6 @@ begin
|
|||||||
UpdateMinMax(ZeroLevel, Result.a.Y, Result.b.Y);
|
UpdateMinMax(ZeroLevel, Result.a.Y, Result.b.Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TAreaSeries.GetLabelDirection(AIndex: Integer): TLabelDirection;
|
|
||||||
const
|
|
||||||
DIR: array [Boolean, Boolean] of TLabelDirection =
|
|
||||||
((ldTop, ldBottom), (ldRight, ldLeft));
|
|
||||||
begin
|
|
||||||
Result :=
|
|
||||||
DIR[IsRotated, UseZeroLevel and (GetGraphPointY(AIndex) < ZeroLevel)];
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TAreaSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TAreaSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
begin
|
begin
|
||||||
GetLegendItemsRect(AItems, AreaBrush);
|
GetLegendItemsRect(AItems, AreaBrush);
|
||||||
@ -1117,6 +1111,11 @@ begin
|
|||||||
Result := FAreaBrush.Color;
|
Result := FAreaBrush.Color;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TAreaSeries.GetZeroLevel: Double;
|
||||||
|
begin
|
||||||
|
Result := IfThen(UseZeroLevel, ZeroLevel, 0.0);
|
||||||
|
end;
|
||||||
|
|
||||||
function TAreaSeries.IsZeroLevelStored: boolean;
|
function TAreaSeries.IsZeroLevelStored: boolean;
|
||||||
begin
|
begin
|
||||||
Result := ZeroLevel <> 0.0;
|
Result := ZeroLevel <> 0.0;
|
||||||
|
Loading…
Reference in New Issue
Block a user