TAChart: Improved legend symbol for TPolarSeries.

This commit is contained in:
wp_xyz 2023-09-14 16:02:15 +02:00
parent dd306bb20e
commit 07f7a1931e
2 changed files with 41 additions and 1 deletions

View File

@ -101,6 +101,17 @@ type
procedure Draw(ADrawer: IChartDrawer; const ARect: TRect); override;
end;
{ TLegendItemLinePointerBrush }
TLegendItemLinePointerBrush = class(TLegendItemLinePointer)
strict protected
FUseBrush: Boolean;
public
constructor Create(APen: TPen; ABrush: TBrush; APointer: TSeriesPointer;
const AText: String);
procedure Draw(ADrawer: IChartDrawer; const ARect: TRect); override;
end;
{ TLegendItemBrushRect }
TLegendItemBrushRect = class(TLegendItem)
@ -516,6 +527,29 @@ begin
FPointer.DrawSize(ADrawer, c, sz, Color, 0.0, FPresetBrush);
end;
{ TLegendItemLinePointerBrush }
constructor TLegendItemLinePointerBrush.Create(APen: TPen; ABrush: TBrush;
APointer: TSeriesPointer; const AText: String);
begin
CreateWithBrush(APen, ABrush, APointer, AText);
end;
procedure TLegendItemLinePointerBrush.Draw(
ADrawer: IChartDrawer; const ARect: TRect);
begin
ADrawer.SetBrush(FBrush);
if Assigned(FPointer) then
begin
ADrawer.FillRect(ARect.Left, (ARect.Top + ARect.Bottom) div 2, ARect.Right, ARect.Bottom);
FPresetBrush := false;
ADrawer.SetBrush(FPointer.Brush);
end;
inherited;
end;
{ TLegendItemBrushRect }
constructor TLegendItemBrushRect.Create(

View File

@ -1357,7 +1357,13 @@ begin
case Legend.Multiplicity of
lmSingle:
AItems.Add(TLegendItemLinePointer.Create(LinePen, p, LegendTextSingle));
if Filled then begin
if ShowPoints then
AItems.Add(TLegendItemLinePointerBrush.Create(LinePen, Brush, p, LegendTextSingle))
else
AItems.Add(TLegendItemBrushPenRect.Create(Brush, LinePen, LegendTextSingle));
end else
AItems.Add(TLegendItemLinePointer.Create(LinePen, p, LegendTextSingle));
lmPoint:
for i := 0 to Count - 1 do begin
li := TLegendItemLinePointer.Create(LinePen, p, LegendTextPoint(i));