diff --git a/components/tachart/tachartaxis.pas b/components/tachart/tachartaxis.pas index 50b0d818d1..b05f0b71e7 100644 --- a/components/tachart/tachartaxis.pas +++ b/components/tachart/tachartaxis.pas @@ -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; diff --git a/components/tachart/tachartutils.pas b/components/tachart/tachartutils.pas index 3818a07edf..5709bcc884 100644 --- a/components/tachart/tachartutils.pas +++ b/components/tachart/tachartutils.pas @@ -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; diff --git a/components/tachart/tadrawersvg.pas b/components/tachart/tadrawersvg.pas index 4d77116b71..6734e9509e 100644 --- a/components/tachart/tadrawersvg.pas +++ b/components/tachart/tadrawersvg.pas @@ -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);