TAChart: Add FormatIfNotEmpty utility function

git-svn-id: trunk@32136 -
This commit is contained in:
ask 2011-08-31 11:05:11 +00:00
parent f32263619c
commit d5ad4ab713
3 changed files with 13 additions and 6 deletions

View File

@ -518,12 +518,10 @@ const
('Left', 'Top', 'Right', 'Bottom');
VISIBLE_NAME: array [Boolean] of String = (' Hidden', '');
INVERTED_NAME: array [Boolean] of String = ('', ' Inverted');
CAPTION_FMT = ' (%s)';
begin
Result :=
SIDE_NAME[Alignment] + VISIBLE_NAME[Visible] + INVERTED_NAME[Inverted];
if Title.Caption <> '' then
Result += Format(CAPTION_FMT, [Title.Caption]);
SIDE_NAME[Alignment] + VISIBLE_NAME[Visible] + INVERTED_NAME[Inverted] +
FormatIfNotEmpty(' (%s)', Title.Caption);
end;
function TChartAxis.GetMarks: TChartAxisMarks;

View File

@ -248,6 +248,8 @@ procedure Exchange(var A, B: String); overload; inline;
procedure ExpandRange(var ALo, AHi: Double; ACoeff: Double); inline;
function FormatIfNotEmpty(AFormat, AStr: String): String; inline;
function InterpolateRGB(AColor1, AColor2: Integer; ACoeff: Double): Integer;
function IntToColorHex(AColor: Integer): String; inline;
@ -360,6 +362,14 @@ begin
AHi += d * ACoeff;
end;
function FormatIfNotEmpty(AFormat, AStr: String): String;
begin
if AStr = '' then
Result := ''
else
Result := Format(AFormat, [AStr]);
end;
function InterpolateRGB(AColor1, AColor2: Integer; ACoeff: Double): Integer;
type
TBytes = packed array [1..4] of Byte;

View File

@ -364,8 +364,7 @@ begin
Result := 'stroke:' + ColorToHex(FPen.FPColor) + ';';
if FPen.Width <> 1 then
Result += 'stroke-width:' + IntToStr(FPen.Width) + ';';
if PEN_DASHARRAY[FPen.Style] <> '' then
Result += 'stroke-dasharray:' + PEN_DASHARRAY[FPen.Style] + ';';
Result += FormatIfNotEmpty('stroke-dasharray:%s;', PEN_DASHARRAY[FPen.Style]);
end;
procedure TSVGDrawer.WriteFmt(const AFormat: String; AParams: array of const);