mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 18:59:08 +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 GetLabelDataPoint(AIndex, AYIndex: Integer): TDoublePoint; virtual;
|
||||||
function GetLabelDirection(AValue: Double;
|
function GetLabelDirection(AValue: Double;
|
||||||
const ACenterLevel: Double): TLabelDirection;
|
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 GetXRange(AX: Double; AIndex: Integer): Double;
|
||||||
function GetZeroLevel: Double; virtual;
|
function GetZeroLevel: Double; virtual;
|
||||||
function HasMissingYValue(AIndex: Integer; AMaxYIndex: Integer = MaxInt): Boolean;
|
function HasMissingYValue(AIndex: Integer; AMaxYIndex: Integer = MaxInt): Boolean;
|
||||||
@ -1547,22 +1547,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBasicPointSeries.GetLegendItemsRect(
|
procedure TBasicPointSeries.GetLegendItemsRect(
|
||||||
AItems: TChartLegendItems; ABrush: TBrush);
|
AItems: TChartLegendItems; ABrush: TBrush; APen: TPen);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
li: TLegendItemBrushRect;
|
li: TLegendItemBrushPenRect;
|
||||||
s: TChartStyle;
|
s: TChartStyle;
|
||||||
begin
|
begin
|
||||||
case Legend.Multiplicity of
|
case Legend.Multiplicity of
|
||||||
lmSingle:
|
lmSingle:
|
||||||
begin
|
begin
|
||||||
li := TLegendItemBrushRect.Create(ABrush, LegendTextSingle);
|
li := TLegendItemBrushPenRect.Create(ABrush, APen, LegendTextSingle);
|
||||||
li.TextFormat := Legend.TextFormat;
|
li.TextFormat := Legend.TextFormat;
|
||||||
AItems.Add(li);
|
AItems.Add(li);
|
||||||
end;
|
end;
|
||||||
lmPoint:
|
lmPoint:
|
||||||
for i := 0 to Count - 1 do begin
|
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.Color := GetColor(i);
|
||||||
li.TextFormat := Legend.TextFormat;
|
li.TextFormat := Legend.TextFormat;
|
||||||
AItems.Add(li);
|
AItems.Add(li);
|
||||||
@ -1570,8 +1570,10 @@ begin
|
|||||||
lmStyle:
|
lmStyle:
|
||||||
if Styles <> nil then
|
if Styles <> nil then
|
||||||
for s in Styles.Styles do
|
for s in Styles.Styles do
|
||||||
AItems.Add(TLegendItemBrushRect.Create(
|
AItems.Add(TLegendItemBrushPenRect.Create(
|
||||||
IfThen(s.UseBrush, s.Brush, ABrush) as TBrush, LegendTextStyle(s)
|
IfThen(s.UseBrush, s.Brush, ABrush) as TBrush,
|
||||||
|
IfThen(s.UsePen, s.Pen, APen) as TPen,
|
||||||
|
LegendTextStyle(s)
|
||||||
));
|
));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -111,6 +111,16 @@ type
|
|||||||
procedure Draw(ADrawer: IChartDrawer; const ARect: TRect); override;
|
procedure Draw(ADrawer: IChartDrawer; const ARect: TRect); override;
|
||||||
end;
|
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)
|
TLegendItemsEnumerator = class(TListEnumerator)
|
||||||
public
|
public
|
||||||
function GetCurrent: TLegendItem;
|
function GetCurrent: TLegendItem;
|
||||||
@ -514,6 +524,21 @@ begin
|
|||||||
ADrawer.Rectangle(ARect);
|
ADrawer.Rectangle(ARect);
|
||||||
end;
|
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 }
|
{ TChartLegend }
|
||||||
|
|
||||||
procedure TChartLegend.AddGroups(AItems: TChartLegendItems);
|
procedure TChartLegend.AddGroups(AItems: TChartLegendItems);
|
||||||
|
@ -651,7 +651,7 @@ end;
|
|||||||
|
|
||||||
procedure TBubbleSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TBubbleSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
begin
|
begin
|
||||||
GetLegendItemsRect(AItems, BubbleBrush);
|
GetLegendItemsRect(AItems, BubbleBrush, BubblePen);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBubbleSeries.GetNearestPoint(const AParams: TNearestPointParams;
|
function TBubbleSeries.GetNearestPoint(const AParams: TNearestPointParams;
|
||||||
|
@ -1580,7 +1580,7 @@ end;
|
|||||||
|
|
||||||
procedure TBarSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TBarSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
begin
|
begin
|
||||||
GetLegendItemsRect(AItems, BarBrush);
|
GetLegendItemsRect(AItems, BarBrush, BarPen);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBarSeries.GetNearestPoint(const AParams: TNearestPointParams;
|
function TBarSeries.GetNearestPoint(const AParams: TNearestPointParams;
|
||||||
@ -2193,7 +2193,7 @@ end;
|
|||||||
|
|
||||||
procedure TAreaSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TAreaSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
begin
|
begin
|
||||||
GetLegendItemsRect(AItems, AreaBrush);
|
GetLegendItemsRect(AItems, AreaBrush, AreaContourPen);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TAreaSeries.GetSeriesColor: TColor;
|
function TAreaSeries.GetSeriesColor: TColor;
|
||||||
|
Loading…
Reference in New Issue
Block a user