mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 02:49:28 +02:00
TAChart: Show pointers in line series legend
git-svn-id: trunk@27461 -
This commit is contained in:
parent
50a7636bc3
commit
ec692bc033
@ -46,6 +46,18 @@ type
|
||||
public
|
||||
constructor Create(APen: TPen; const AText: String);
|
||||
procedure Draw(ACanvas: TCanvas; const ARect: TRect); override;
|
||||
property Pen: TPen read FPen;
|
||||
end;
|
||||
|
||||
{ TLegendItemLinePointer }
|
||||
|
||||
TLegendItemLinePointer = class(TLegendItemLine)
|
||||
protected
|
||||
FPointer: TSeriesPointer;
|
||||
public
|
||||
constructor Create(
|
||||
APen: TPen; APointer: TSeriesPointer; const AText: String);
|
||||
procedure Draw(ACanvas: TCanvas; const ARect: TRect); override;
|
||||
end;
|
||||
|
||||
{ TLegendItemBrushRect }
|
||||
@ -165,11 +177,31 @@ var
|
||||
y: Integer;
|
||||
begin
|
||||
inherited Draw(ACanvas, ARect);
|
||||
if FPen = nil then exit;
|
||||
ACanvas.Pen.Assign(FPen);
|
||||
y := (ARect.Top + ARect.Bottom) div 2;
|
||||
ACanvas.Line(ARect.Left, y, ARect.Right, y);
|
||||
end;
|
||||
|
||||
{ TLegendItemLinePointer }
|
||||
|
||||
constructor TLegendItemLinePointer.Create(
|
||||
APen: TPen; APointer: TSeriesPointer; const AText: String);
|
||||
begin
|
||||
inherited Create(APen, AText);
|
||||
FPointer := APointer;
|
||||
end;
|
||||
|
||||
procedure TLegendItemLinePointer.Draw(ACanvas: TCanvas; const ARect: TRect);
|
||||
var
|
||||
c: TPoint;
|
||||
begin
|
||||
inherited Draw(ACanvas, ARect);
|
||||
if FPointer = nil then exit;
|
||||
c := CenterPoint(ARect);
|
||||
FPointer.Draw(ACanvas, c, clTAColor);
|
||||
end;
|
||||
|
||||
{ TLegendItemBrushRect }
|
||||
|
||||
constructor TLegendItemBrushRect.Create(ABrush: TBrush; const AText: String);
|
||||
|
@ -498,8 +498,19 @@ begin
|
||||
end;
|
||||
|
||||
procedure TLineSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||
var
|
||||
lp: TPen;
|
||||
p: TSeriesPointer;
|
||||
begin
|
||||
AItems.Add(TLegendItemLine.Create(LinePen, Title));
|
||||
if LineType = ltNone then
|
||||
lp := nil
|
||||
else
|
||||
lp := LinePen;
|
||||
if ShowPoints then
|
||||
p := Pointer
|
||||
else
|
||||
p := nil;
|
||||
AItems.Add(TLegendItemLinePointer.Create(lp, p, Title));
|
||||
end;
|
||||
|
||||
function TLineSeries.GetSeriesColor: TColor;
|
||||
|
Loading…
Reference in New Issue
Block a user