mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:59:20 +02:00
TAChart: Add Marks.Shape property
git-svn-id: trunk@38561 -
This commit is contained in:
parent
c38cc4533e
commit
3464f50fbd
@ -29,6 +29,7 @@ type
|
|||||||
FC: TDoublePoint;
|
FC: TDoublePoint;
|
||||||
FR: TDoublePoint;
|
FR: TDoublePoint;
|
||||||
constructor InitBoundingBox(AX1, AY1, AX2, AY2: Integer);
|
constructor InitBoundingBox(AX1, AY1, AX2, AY2: Integer);
|
||||||
|
constructor InitRadius(ARX, ARY: Double);
|
||||||
public
|
public
|
||||||
function GetPoint(AParametricAngle: Double): TDoublePoint;
|
function GetPoint(AParametricAngle: Double): TDoublePoint;
|
||||||
function TesselateRadialPie(
|
function TesselateRadialPie(
|
||||||
@ -547,6 +548,12 @@ begin
|
|||||||
FR.Y := Abs(AY1 - AY2) / 2;
|
FR.Y := Abs(AY1 - AY2) / 2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
constructor TEllipse.InitRadius(ARX, ARY: Double);
|
||||||
|
begin
|
||||||
|
FC := ZeroDoublePoint;
|
||||||
|
FR := DoublePoint(ARX, ARY);
|
||||||
|
end;
|
||||||
|
|
||||||
// Represent the ellipse sector with a polygon on an integer grid.
|
// Represent the ellipse sector with a polygon on an integer grid.
|
||||||
// Polygon vertices are no more then AStep pixels apart.
|
// Polygon vertices are no more then AStep pixels apart.
|
||||||
function TEllipse.TesselateRadialPie(
|
function TEllipse.TesselateRadialPie(
|
||||||
|
@ -114,7 +114,8 @@ type
|
|||||||
procedure DrawLabel(
|
procedure DrawLabel(
|
||||||
ADrawer: IChartDrawer; const ADataPoint, ALabelCenter: TPoint;
|
ADrawer: IChartDrawer; const ADataPoint, ALabelCenter: TPoint;
|
||||||
const AText: String; var APrevLabelPoly: TPointArray);
|
const AText: String; var APrevLabelPoly: TPointArray);
|
||||||
function GetLabelPolygon(ADrawer: IChartDrawer; ASize: TPoint): TPointArray;
|
function GetLabelPolygon(
|
||||||
|
ADrawer: IChartDrawer; ASize: TPoint): TPointArray; virtual;
|
||||||
function MeasureLabel(ADrawer: IChartDrawer; const AText: String): TSize;
|
function MeasureLabel(ADrawer: IChartDrawer; const AText: String): TSize;
|
||||||
public
|
public
|
||||||
// If false, labels may overlap axises and legend.
|
// If false, labels may overlap axises and legend.
|
||||||
@ -171,6 +172,7 @@ type
|
|||||||
TChartArrow = class;
|
TChartArrow = class;
|
||||||
|
|
||||||
TChartMarkAttachment = (maDefault, maEdge, maCenter);
|
TChartMarkAttachment = (maDefault, maEdge, maCenter);
|
||||||
|
TChartMarkLabelShape = (cmsRectangle, cmsEllipse);
|
||||||
|
|
||||||
{ TGenericChartMarks }
|
{ TGenericChartMarks }
|
||||||
|
|
||||||
@ -185,6 +187,7 @@ type
|
|||||||
FArrow: TChartArrow;
|
FArrow: TChartArrow;
|
||||||
FAttachment: TChartMarkAttachment;
|
FAttachment: TChartMarkAttachment;
|
||||||
FFrame: _TFramePen;
|
FFrame: _TFramePen;
|
||||||
|
FShape: TChartMarkLabelShape;
|
||||||
FYIndex: Integer;
|
FYIndex: Integer;
|
||||||
function GetDistanceToCenter: Boolean;
|
function GetDistanceToCenter: Boolean;
|
||||||
procedure SetArrow(AValue: TChartArrow);
|
procedure SetArrow(AValue: TChartArrow);
|
||||||
@ -196,6 +199,7 @@ type
|
|||||||
procedure SetLabelBrush(AValue: _TLabelBrush);
|
procedure SetLabelBrush(AValue: _TLabelBrush);
|
||||||
procedure SetLabelFont(AValue: TFont);
|
procedure SetLabelFont(AValue: TFont);
|
||||||
procedure SetLinkPen(AValue: _TLinkPen);
|
procedure SetLinkPen(AValue: _TLinkPen);
|
||||||
|
procedure SetShape(AValue: TChartMarkLabelShape);
|
||||||
procedure SetStyle(AValue: TSeriesMarksStyle);
|
procedure SetStyle(AValue: TSeriesMarksStyle);
|
||||||
procedure SetYIndex(AValue: Integer);
|
procedure SetYIndex(AValue: Integer);
|
||||||
strict protected
|
strict protected
|
||||||
@ -220,6 +224,8 @@ type
|
|||||||
public
|
public
|
||||||
procedure Assign(ASource: TPersistent); override;
|
procedure Assign(ASource: TPersistent); override;
|
||||||
function CenterOffset(ADrawer: IChartDrawer; const AText: String): TSize;
|
function CenterOffset(ADrawer: IChartDrawer; const AText: String): TSize;
|
||||||
|
function GetLabelPolygon(
|
||||||
|
ADrawer: IChartDrawer; ASize: TPoint): TPointArray; override;
|
||||||
function IsMarkLabelsVisible: Boolean;
|
function IsMarkLabelsVisible: Boolean;
|
||||||
procedure SetAdditionalAngle(AAngle: Double);
|
procedure SetAdditionalAngle(AAngle: Double);
|
||||||
public
|
public
|
||||||
@ -241,6 +247,8 @@ type
|
|||||||
property Clipped;
|
property Clipped;
|
||||||
property Distance: TChartDistance read FDistance write SetDistance;
|
property Distance: TChartDistance read FDistance write SetDistance;
|
||||||
property LabelFont: TFont read FLabelFont write SetLabelFont;
|
property LabelFont: TFont read FLabelFont write SetLabelFont;
|
||||||
|
property Shape: TChartMarkLabelShape
|
||||||
|
read FShape write SetShape default cmsRectangle;
|
||||||
property Visible default true;
|
property Visible default true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -824,6 +832,27 @@ begin
|
|||||||
Result := LabelFont;
|
Result := LabelFont;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TGenericChartMarks.GetLabelPolygon(ADrawer: IChartDrawer;
|
||||||
|
ASize: TPoint): TPointArray;
|
||||||
|
var
|
||||||
|
e: TEllipse;
|
||||||
|
a: Double;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
AddMargins(ADrawer, ASize);
|
||||||
|
case Shape of
|
||||||
|
cmsRectangle: Result := RotateRect(ASize, GetLabelAngle);
|
||||||
|
cmsEllipse: begin
|
||||||
|
e.InitRadius(ASize.X / 2, ASize.Y / 2);
|
||||||
|
Result := e.TesselateRadialPie(0, 2 * Pi, 3);
|
||||||
|
SetLength(Result, Length(Result) - 1);
|
||||||
|
a := GetLabelAngle;
|
||||||
|
for i := 0 to High(Result) do
|
||||||
|
Result[i] := RotatePoint(Result[i], a);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TGenericChartMarks.GetLinkPen: TChartPen;
|
function TGenericChartMarks.GetLinkPen: TChartPen;
|
||||||
begin
|
begin
|
||||||
Result := LinkPen;
|
Result := LinkPen;
|
||||||
@ -907,6 +936,13 @@ begin
|
|||||||
StyleChanged(Self);
|
StyleChanged(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGenericChartMarks.SetShape(AValue: TChartMarkLabelShape);
|
||||||
|
begin
|
||||||
|
if FShape = AValue then exit;
|
||||||
|
FShape := AValue;
|
||||||
|
StyleChanged(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TGenericChartMarks.SetStyle(AValue: TSeriesMarksStyle);
|
procedure TGenericChartMarks.SetStyle(AValue: TSeriesMarksStyle);
|
||||||
begin
|
begin
|
||||||
if FStyle = AValue then exit;
|
if FStyle = AValue then exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user