mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-05 12:13:30 +01:00
TAChart: Add per-style legend items
git-svn-id: trunk@37528 -
This commit is contained in:
parent
c0a075c800
commit
38164a5dd7
@ -77,6 +77,7 @@ type
|
||||
strict protected
|
||||
function GetIndex: Integer; override;
|
||||
function LegendTextSingle: String;
|
||||
function LegendTextStyle(AStyle: TChartStyle): String;
|
||||
procedure SetIndex(AValue: Integer); override;
|
||||
function TitleIsStored: Boolean; virtual;
|
||||
|
||||
@ -446,6 +447,14 @@ begin
|
||||
Result := Format(Legend.Format, [Title, Index]);
|
||||
end;
|
||||
|
||||
function TCustomChartSeries.LegendTextStyle(AStyle: TChartStyle): String;
|
||||
begin
|
||||
if Legend.Format = '' then
|
||||
Result := AStyle.Text
|
||||
else
|
||||
Result := Format(Legend.Format, [AStyle.Text, AStyle.Index]);
|
||||
end;
|
||||
|
||||
procedure TCustomChartSeries.ReadState(Reader: TReader);
|
||||
begin
|
||||
inherited ReadState(Reader);
|
||||
@ -964,6 +973,7 @@ procedure TBasicPointSeries.GetLegendItemsRect(
|
||||
var
|
||||
i: Integer;
|
||||
li: TLegendItemBrushRect;
|
||||
s: TChartStyle;
|
||||
begin
|
||||
case Legend.Multiplicity of
|
||||
lmSingle:
|
||||
@ -974,6 +984,12 @@ begin
|
||||
li.Color := GetColor(i);
|
||||
AItems.Add(li);
|
||||
end;
|
||||
lmStyle:
|
||||
if Styles <> nil then
|
||||
for s in Styles.Styles do
|
||||
AItems.Add(TLegendItemBrushRect.Create(
|
||||
IfThen(s.UseBrush, s.Brush, ABrush) as TBrush, LegendTextStyle(s)
|
||||
));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -226,7 +226,7 @@ type
|
||||
property Visible default false;
|
||||
end;
|
||||
|
||||
TLegendMultiplicity = (lmSingle, lmPoint);
|
||||
TLegendMultiplicity = (lmSingle, lmPoint, lmStyle);
|
||||
|
||||
TLegendItemCreateEvent = procedure (
|
||||
AItem: TLegendItem; AIndex: Integer) of object;
|
||||
|
||||
@ -322,7 +322,7 @@ implementation
|
||||
|
||||
uses
|
||||
GraphMath, LResources, Math, PropEdits, SysUtils,
|
||||
TADrawerCanvas, TAGeometry, TAGraph, TAMath;
|
||||
TADrawerCanvas, TAGeometry, TAGraph, TAMath, TAStyles;
|
||||
|
||||
{ TLineSeries }
|
||||
|
||||
@ -538,6 +538,7 @@ var
|
||||
p: TSeriesPointer;
|
||||
i: Integer;
|
||||
li: TLegendItemLinePointer;
|
||||
s: TChartStyle;
|
||||
begin
|
||||
if LineType = ltNone then
|
||||
lp := nil
|
||||
@ -550,13 +551,19 @@ begin
|
||||
case Legend.Multiplicity of
|
||||
lmSingle:
|
||||
AItems.Add(TLegendItemLinePointer.Create(lp, p, LegendTextSingle));
|
||||
lmPoint: begin
|
||||
lmPoint:
|
||||
for i := 0 to Count - 1 do begin
|
||||
li := TLegendItemLinePointer.Create(lp, p, LegendTextPoint(i));
|
||||
li.Color := GetColor(i);
|
||||
AItems.Add(li);
|
||||
end;
|
||||
end;
|
||||
lmStyle:
|
||||
if Styles <> nil then
|
||||
for s in Styles.Styles do
|
||||
AItems.Add(TLegendItemLinePointer.Create(
|
||||
IfThen((lp <> nil) and s.UsePen, s.Pen, lp) as TPen,
|
||||
p, LegendTextStyle(s)
|
||||
));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user