mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 22:59:15 +02:00
TAChart: Use Legend.Format in TColorMapSeries format for per-point multiplicity
git-svn-id: trunk@39588 -
This commit is contained in:
parent
bb6b47fcf8
commit
2f0a0ecdc6
@ -1291,21 +1291,38 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TColorMapSeries.GetLegendItems(AItems: TChartLegendItems);
|
procedure TColorMapSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||||
|
|
||||||
|
function PrepareFormats: TStrings;
|
||||||
|
const
|
||||||
|
FORMAT_DEF = 'z ≤ %1:g|%g < z ≤ %g|%g < z';
|
||||||
|
begin
|
||||||
|
Result := TStringList.Create;
|
||||||
|
with Result do
|
||||||
|
try
|
||||||
|
Delimiter := '|';
|
||||||
|
DelimitedText := IfThen(Legend.Format = '', FORMAT_DEF, Legend.Format);
|
||||||
|
while Count < 3 do
|
||||||
|
Add(Strings[Count - 1]);
|
||||||
|
except
|
||||||
|
Result.Free;
|
||||||
|
raise;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
prev: Double;
|
prev: Double;
|
||||||
|
formats: TStrings;
|
||||||
|
|
||||||
function ItemTitle(AIndex: Integer; const AText: String; AX: Double): String;
|
function ItemTitle(AIndex: Integer; const AText: String; AX: Double): String;
|
||||||
const
|
|
||||||
FORMATS: array [1..3] of String = ('z ≤ %1:g', '%g < z ≤ %g', '%g < z');
|
|
||||||
var
|
var
|
||||||
idx: Integer;
|
idx: Integer;
|
||||||
begin
|
begin
|
||||||
if AText <> '' then exit(AText);
|
if AText <> '' then exit(AText);
|
||||||
if ColorSource.Count = 1 then exit('');
|
if ColorSource.Count = 1 then exit('');
|
||||||
if AIndex = 0 then idx := 1
|
if AIndex = 0 then idx := 0
|
||||||
else if AIndex = ColorSource.Count - 1 then idx := 3
|
else if AIndex = ColorSource.Count - 1 then idx := 2
|
||||||
else idx := 2;
|
else idx := 1;
|
||||||
Result := Format(FORMATS[idx], [prev, AX]);
|
Result := Format(formats[idx], [prev, AX]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure MakePointItems;
|
procedure MakePointItems;
|
||||||
@ -1315,22 +1332,27 @@ var
|
|||||||
li: TLegendItem;
|
li: TLegendItem;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
prev := 0.0;
|
prev := ColorSource[0]^.X;
|
||||||
prevColor := clTAColor;
|
prevColor := clTAColor;
|
||||||
for i := 0 to ColorSource.Count - 1 do
|
formats := PrepareFormats;
|
||||||
with ColorSource[i]^ do begin
|
try
|
||||||
t := ItemTitle(i, Text, X);
|
for i := 0 to ColorSource.Count - 1 do
|
||||||
if Interpolate then
|
with ColorSource[i]^ do begin
|
||||||
li := TLegendItemColorMap.Create(
|
t := ItemTitle(i, Text, X);
|
||||||
ColorDef(prevColor, Color), Color, ParentChart.Legend.SymbolFrame, t)
|
if Interpolate then
|
||||||
else begin
|
li := TLegendItemColorMap.Create(
|
||||||
li := TLegendItemBrushRect.Create(Brush, t);
|
ColorDef(prevColor, Color), Color, ParentChart.Legend.SymbolFrame, t)
|
||||||
li.Color := Color;
|
else begin
|
||||||
|
li := TLegendItemBrushRect.Create(Brush, t);
|
||||||
|
li.Color := Color;
|
||||||
|
end;
|
||||||
|
AItems.Add(li);
|
||||||
|
prev := X;
|
||||||
|
prevColor := Color;
|
||||||
end;
|
end;
|
||||||
AItems.Add(li);
|
finally
|
||||||
prev := X;
|
formats.Free;
|
||||||
prevColor := Color;
|
end;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -1338,7 +1360,7 @@ begin
|
|||||||
lmSingle:
|
lmSingle:
|
||||||
AItems.Add(TLegendItemBrushRect.Create(Brush, LegendTextSingle));
|
AItems.Add(TLegendItemBrushRect.Create(Brush, LegendTextSingle));
|
||||||
lmPoint:
|
lmPoint:
|
||||||
if ColorSource <> nil then
|
if (ColorSource <> nil) and (ColorSource.Count > 0) then
|
||||||
MakePointItems;
|
MakePointItems;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user