TAChart: Show pointers in line series legend

git-svn-id: trunk@27461 -
This commit is contained in:
ask 2010-09-26 02:43:12 +00:00
parent 50a7636bc3
commit ec692bc033
2 changed files with 44 additions and 1 deletions

View File

@ -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);

View File

@ -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;