mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 16:55:55 +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
|
public
|
||||||
constructor Create(APen: TPen; const AText: String);
|
constructor Create(APen: TPen; const AText: String);
|
||||||
procedure Draw(ACanvas: TCanvas; const ARect: TRect); override;
|
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;
|
end;
|
||||||
|
|
||||||
{ TLegendItemBrushRect }
|
{ TLegendItemBrushRect }
|
||||||
@ -165,11 +177,31 @@ var
|
|||||||
y: Integer;
|
y: Integer;
|
||||||
begin
|
begin
|
||||||
inherited Draw(ACanvas, ARect);
|
inherited Draw(ACanvas, ARect);
|
||||||
|
if FPen = nil then exit;
|
||||||
ACanvas.Pen.Assign(FPen);
|
ACanvas.Pen.Assign(FPen);
|
||||||
y := (ARect.Top + ARect.Bottom) div 2;
|
y := (ARect.Top + ARect.Bottom) div 2;
|
||||||
ACanvas.Line(ARect.Left, y, ARect.Right, y);
|
ACanvas.Line(ARect.Left, y, ARect.Right, y);
|
||||||
end;
|
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 }
|
{ TLegendItemBrushRect }
|
||||||
|
|
||||||
constructor TLegendItemBrushRect.Create(ABrush: TBrush; const AText: String);
|
constructor TLegendItemBrushRect.Create(ABrush: TBrush; const AText: String);
|
||||||
|
@ -498,8 +498,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLineSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TLineSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
|
var
|
||||||
|
lp: TPen;
|
||||||
|
p: TSeriesPointer;
|
||||||
begin
|
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;
|
end;
|
||||||
|
|
||||||
function TLineSeries.GetSeriesColor: TColor;
|
function TLineSeries.GetSeriesColor: TColor;
|
||||||
|
Loading…
Reference in New Issue
Block a user