TAChart: Accept date/time strings in TListChartSource.DataPoints

git-svn-id: trunk@56940 -
This commit is contained in:
wp 2018-01-03 17:36:12 +00:00
parent 3d107d6533
commit 2a5154bef1
2 changed files with 16 additions and 3 deletions

View File

@ -351,6 +351,8 @@ function Split(
// Accept both locale-specific and default decimal separators.
function StrToFloatDefSep(const AStr: String): Double;
// .. or date/time values
function StrToFloatOrDateTimeDef(const AStr: String): Double;
// Call this to silence 'parameter is unused' hint
procedure Unused(const A1);
@ -532,6 +534,16 @@ begin
Result := 0.0;
end;
function StrToFloatOrDateTimeDef(const AStr: String): Double;
begin
if
not TryStrToFloat(AStr, Result, DefSeparatorSettings) and
not TryStrToFloat(AStr, Result) and
not TryStrToDateTime(AStr, Result)
then
Result := 0.0;
end;
{$PUSH}{$HINTS OFF}
procedure Unused(const A1);
begin

View File

@ -334,17 +334,18 @@ var
var
i: Integer;
s: String;
begin
parts := Split(AString);
try
if FSource.YCount + 3 < Cardinal(parts.Count) then
FSource.YCount := parts.Count - 3;
with ADataItem^ do begin
X := StrToFloatDefSep(NextPart);
X := StrToFloatOrDateTimeDef(NextPart);
if FSource.YCount > 0 then begin
Y := StrToFloatDefSep(NextPart);
Y := StrToFloatOrDateTimeDef(NextPart);
for i := 0 to High(YList) do
YList[i] := StrToFloatDefSep(NextPart);
YList[i] := StrToFloatOrDateTimeDef(NextPart);
end;
Color := StrToIntDef(NextPart, clTAColor);
Text := NextPart;