mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 03:58:09 +02:00
TAChart: Add TLegendItemBrushPenRect to display pen in legend icons of TBarSeries, TAreaSeries and TBubbleSeries.
git-svn-id: trunk@62772 -
This commit is contained in:
parent
57dc078ec5
commit
b198ba1129
@ -303,7 +303,7 @@ type
|
||||
function GetLabelDataPoint(AIndex, AYIndex: Integer): TDoublePoint; virtual;
|
||||
function GetLabelDirection(AValue: Double;
|
||||
const ACenterLevel: Double): TLabelDirection;
|
||||
procedure GetLegendItemsRect(AItems: TChartLegendItems; ABrush: TBrush);
|
||||
procedure GetLegendItemsRect(AItems: TChartLegendItems; ABrush: TBrush; APen: TPen);
|
||||
function GetXRange(AX: Double; AIndex: Integer): Double;
|
||||
function GetZeroLevel: Double; virtual;
|
||||
function HasMissingYValue(AIndex: Integer; AMaxYIndex: Integer = MaxInt): Boolean;
|
||||
@ -1547,22 +1547,22 @@ begin
|
||||
end;
|
||||
|
||||
procedure TBasicPointSeries.GetLegendItemsRect(
|
||||
AItems: TChartLegendItems; ABrush: TBrush);
|
||||
AItems: TChartLegendItems; ABrush: TBrush; APen: TPen);
|
||||
var
|
||||
i: Integer;
|
||||
li: TLegendItemBrushRect;
|
||||
li: TLegendItemBrushPenRect;
|
||||
s: TChartStyle;
|
||||
begin
|
||||
case Legend.Multiplicity of
|
||||
lmSingle:
|
||||
begin
|
||||
li := TLegendItemBrushRect.Create(ABrush, LegendTextSingle);
|
||||
li := TLegendItemBrushPenRect.Create(ABrush, APen, LegendTextSingle);
|
||||
li.TextFormat := Legend.TextFormat;
|
||||
AItems.Add(li);
|
||||
end;
|
||||
lmPoint:
|
||||
for i := 0 to Count - 1 do begin
|
||||
li := TLegendItemBrushRect.Create(ABrush, LegendTextPoint(i));
|
||||
li := TLegendItemBrushPenRect.Create(ABrush, APen, LegendTextPoint(i));
|
||||
li.Color := GetColor(i);
|
||||
li.TextFormat := Legend.TextFormat;
|
||||
AItems.Add(li);
|
||||
@ -1570,8 +1570,10 @@ begin
|
||||
lmStyle:
|
||||
if Styles <> nil then
|
||||
for s in Styles.Styles do
|
||||
AItems.Add(TLegendItemBrushRect.Create(
|
||||
IfThen(s.UseBrush, s.Brush, ABrush) as TBrush, LegendTextStyle(s)
|
||||
AItems.Add(TLegendItemBrushPenRect.Create(
|
||||
IfThen(s.UseBrush, s.Brush, ABrush) as TBrush,
|
||||
IfThen(s.UsePen, s.Pen, APen) as TPen,
|
||||
LegendTextStyle(s)
|
||||
));
|
||||
end;
|
||||
end;
|
||||
|
@ -111,6 +111,16 @@ type
|
||||
procedure Draw(ADrawer: IChartDrawer; const ARect: TRect); override;
|
||||
end;
|
||||
|
||||
{ TLegendItemBrushPenRect }
|
||||
|
||||
TLegendItemBrushPenRect = class(TLegendItemBrushRect)
|
||||
strict private
|
||||
FPen: TFPCustomPen;
|
||||
public
|
||||
constructor Create(ABrush: TFPCustomBrush; APen: TFPCustomPen; const AText: String);
|
||||
procedure Draw(ADrawer: IChartDrawer; const ARect: TRect); override;
|
||||
end;
|
||||
|
||||
TLegendItemsEnumerator = class(TListEnumerator)
|
||||
public
|
||||
function GetCurrent: TLegendItem;
|
||||
@ -514,6 +524,21 @@ begin
|
||||
ADrawer.Rectangle(ARect);
|
||||
end;
|
||||
|
||||
{ TLegendItemBrushPenRect }
|
||||
|
||||
constructor TLegendItemBrushPenRect.Create(
|
||||
ABrush: TFPCustomBrush; APen: TFPCustomPen; const AText: String);
|
||||
begin
|
||||
inherited Create(ABrush, AText);
|
||||
FPen := APen;
|
||||
end;
|
||||
|
||||
procedure TLegendItemBrushPenRect.Draw(ADrawer: IChartDrawer; const ARect: TRect);
|
||||
begin
|
||||
ADrawer.Pen := FPen;
|
||||
inherited Draw(ADrawer, ARect);
|
||||
end;
|
||||
|
||||
{ TChartLegend }
|
||||
|
||||
procedure TChartLegend.AddGroups(AItems: TChartLegendItems);
|
||||
|
@ -651,7 +651,7 @@ end;
|
||||
|
||||
procedure TBubbleSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||
begin
|
||||
GetLegendItemsRect(AItems, BubbleBrush);
|
||||
GetLegendItemsRect(AItems, BubbleBrush, BubblePen);
|
||||
end;
|
||||
|
||||
function TBubbleSeries.GetNearestPoint(const AParams: TNearestPointParams;
|
||||
|
@ -1580,7 +1580,7 @@ end;
|
||||
|
||||
procedure TBarSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||
begin
|
||||
GetLegendItemsRect(AItems, BarBrush);
|
||||
GetLegendItemsRect(AItems, BarBrush, BarPen);
|
||||
end;
|
||||
|
||||
function TBarSeries.GetNearestPoint(const AParams: TNearestPointParams;
|
||||
@ -2193,7 +2193,7 @@ end;
|
||||
|
||||
procedure TAreaSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||
begin
|
||||
GetLegendItemsRect(AItems, AreaBrush);
|
||||
GetLegendItemsRect(AItems, AreaBrush, AreaContourPen);
|
||||
end;
|
||||
|
||||
function TAreaSeries.GetSeriesColor: TColor;
|
||||
|
Loading…
Reference in New Issue
Block a user