mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-26 10:09:51 +02:00
TAChart: Extract utility function Split
git-svn-id: trunk@39600 -
This commit is contained in:
parent
607dd7c75f
commit
b7d4efbbb2
@ -306,6 +306,9 @@ function RoundChecked(A: Double): Integer; inline;
|
||||
|
||||
procedure SetPropDefaults(AObject: TPersistent; APropNames: array of String);
|
||||
|
||||
function Split(
|
||||
AString: String; ADest: TStrings = nil; ADelimiter: Char = '|'): TStrings;
|
||||
|
||||
// Accept both locale-specific and default decimal separators.
|
||||
function StrToFloatDefSep(const AStr: String): Double;
|
||||
|
||||
@ -474,6 +477,16 @@ end;
|
||||
var
|
||||
DefSeparatorSettings: TFormatSettings;
|
||||
|
||||
function Split(AString: String; ADest: TStrings; ADelimiter: Char): TStrings;
|
||||
begin
|
||||
Result := ADest;
|
||||
if Result = nil then
|
||||
Result := TStringList.Create;
|
||||
Result.Delimiter := ADelimiter;
|
||||
Result.StrictDelimiter := true;
|
||||
Result.DelimitedText := AString;
|
||||
end;
|
||||
|
||||
function StrToFloatDefSep(const AStr: String): Double;
|
||||
begin
|
||||
if
|
||||
|
@ -338,14 +338,11 @@ end;
|
||||
|
||||
procedure TChartAxisIntervalParams.ParseNiceSteps;
|
||||
var
|
||||
parts: TStringList;
|
||||
parts: TStrings;
|
||||
i: Integer;
|
||||
begin
|
||||
parts := TStringList.Create;
|
||||
parts := Split(IfThen(NiceSteps = '', DEF_INTERVAL_STEPS, NiceSteps));
|
||||
try
|
||||
parts.Delimiter := '|';
|
||||
parts.StrictDelimiter := true;
|
||||
parts.DelimitedText := IfThen(NiceSteps = '', DEF_INTERVAL_STEPS, NiceSteps);
|
||||
SetLength(FStepValues, parts.Count);
|
||||
for i := 0 to parts.Count - 1 do
|
||||
FStepValues[i] := StrToFloatDefSep(parts[i]);
|
||||
|
@ -1296,11 +1296,9 @@ procedure TColorMapSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||
const
|
||||
FORMAT_DEF = 'z ≤ %1:g|%g < z ≤ %g|%g < z';
|
||||
begin
|
||||
Result := TStringList.Create;
|
||||
Result := Split(IfThen(Legend.Format = '', FORMAT_DEF, Legend.Format));
|
||||
with Result do
|
||||
try
|
||||
Delimiter := '|';
|
||||
DelimitedText := IfThen(Legend.Format = '', FORMAT_DEF, Legend.Format);
|
||||
while Count < 3 do
|
||||
Add(Strings[Count - 1]);
|
||||
except
|
||||
|
@ -317,7 +317,7 @@ procedure TListChartSourceStrings.Parse(
|
||||
AString: String; ADataItem: PChartDataItem);
|
||||
var
|
||||
p: Integer = 0;
|
||||
parts: TStringList;
|
||||
parts: TStrings;
|
||||
|
||||
function NextPart: String;
|
||||
begin
|
||||
@ -331,11 +331,8 @@ var
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
parts := TStringList.Create;
|
||||
parts := Split(AString);
|
||||
try
|
||||
parts.Delimiter := '|';
|
||||
parts.StrictDelimiter := true;
|
||||
parts.DelimitedText := AString;
|
||||
if FSource.YCount + 3 < Cardinal(parts.Count) then
|
||||
FSource.YCount := parts.Count - 3;
|
||||
with ADataItem^ do begin
|
||||
|
Loading…
Reference in New Issue
Block a user