mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 09:49:22 +02:00
TAChart: Some optimizations from patches by Marcin Wiazowski. Decimal separator test for TListChartSource.DataPoints.
git-svn-id: trunk@60491 -
This commit is contained in:
parent
cd2e076da1
commit
5207c624ac
@ -323,6 +323,9 @@ const
|
||||
((cotNone, cotSecond), (cotFirst, cotBoth));
|
||||
ORIENTATION_UNITS_PER_DEG = 10;
|
||||
|
||||
var
|
||||
DefSeparatorSettings: TFormatSettings;
|
||||
|
||||
function BoundsSize(ALeft, ATop: Integer; ASize: TSize): TRect; inline;
|
||||
|
||||
function Deg16ToRad(ADeg16: Integer): Double; inline;
|
||||
@ -523,9 +526,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
DefSeparatorSettings: TFormatSettings;
|
||||
|
||||
function Split(AString: String; ADest: TStrings; ADelimiter: Char): TStrings;
|
||||
begin
|
||||
Result := ADest;
|
||||
|
@ -1069,10 +1069,13 @@ end;
|
||||
|
||||
procedure TChartSeries.SetSource(AValue: TCustomChartSource);
|
||||
begin
|
||||
if FSource = AValue then exit;
|
||||
if AValue = FBuiltinSource then
|
||||
AValue := nil;
|
||||
if FSource = AValue then
|
||||
exit;
|
||||
CheckSource(AValue);
|
||||
if FListener.IsListening then
|
||||
Source.Broadcaster.Unsubscribe(FListener);
|
||||
CheckSource(AValue);
|
||||
FSource := AValue;
|
||||
Source.Broadcaster.Subscribe(FListener);
|
||||
SourceChanged(Self);
|
||||
@ -1122,7 +1125,7 @@ end;
|
||||
|
||||
procedure TChartSeries.SourceChanged(ASender: TObject);
|
||||
begin
|
||||
if ASender is TCustomChartSource then
|
||||
if (ASender <> FBuiltinSource) and (ASender is TCustomChartSource) then
|
||||
try
|
||||
CheckSource(TCustomChartSource(ASender));
|
||||
except
|
||||
|
@ -107,8 +107,6 @@ uses
|
||||
const
|
||||
RECT_FMT =
|
||||
'<rect x="%d" y="%d" width="%d" height="%d" style="%s"/>';
|
||||
var
|
||||
fmtSettings: TFormatSettings;
|
||||
|
||||
function EscapeXML(const AText: String): String;
|
||||
var
|
||||
@ -139,12 +137,12 @@ end;
|
||||
|
||||
function DP2S(AValue: TDoublePoint): String;
|
||||
begin
|
||||
Result := Format('%g,%g', [AValue.X, AValue.Y], fmtSettings);
|
||||
Result := Format('%g,%g', [AValue.X, AValue.Y], DefSeparatorSettings);
|
||||
end;
|
||||
|
||||
function F2S(AValue: Double): String;
|
||||
begin
|
||||
Result := FloatToStr(AValue, fmtSettings);
|
||||
Result := FloatToStr(AValue, DefSeparatorSettings);
|
||||
end;
|
||||
|
||||
function SVGGetFontOrientationFunc(AFont: TFPCustomFont): Integer;
|
||||
@ -534,7 +532,7 @@ begin
|
||||
stext := Format('x="%d" y="%d"', [p.X, p.Y]);
|
||||
if FFontOrientation <> 0 then
|
||||
stext := stext + Format(' transform="rotate(%g,%d,%d)"',
|
||||
[-FFontOrientation*0.1, p.X, p.Y], fmtSettings);
|
||||
[-FFontOrientation*0.1, p.X, p.Y], DefSeparatorSettings);
|
||||
|
||||
sstyle := Format('fill:%s; font-family:''%s''; font-size:%dpt;',
|
||||
[ColorToHex(GetFontColor), GetFontName, round(FFont.SizeInPoints)]);
|
||||
@ -609,7 +607,7 @@ end;
|
||||
|
||||
procedure TSVGDrawer.WriteFmt(const AFormat: String; AParams: array of const);
|
||||
begin
|
||||
WriteStr(Format(AFormat, AParams, fmtSettings));
|
||||
WriteStr(Format(AFormat, AParams, DefSeparatorSettings));
|
||||
end;
|
||||
|
||||
procedure TSVGDrawer.WriteStr(const AString: String);
|
||||
@ -636,9 +634,5 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
fmtSettings := DefaultFormatSettings;
|
||||
fmtSettings.DecimalSeparator := '.';
|
||||
|
||||
end.
|
||||
|
||||
|
@ -315,20 +315,17 @@ end;
|
||||
function TListChartSourceStrings.Get(Index: Integer): String;
|
||||
var
|
||||
i: Integer;
|
||||
fs: TFormatSettings;
|
||||
begin
|
||||
fs := DefaultFormatSettings;
|
||||
fs.DecimalSeparator := '.';
|
||||
with FSource[Index]^ do begin
|
||||
Result := '';
|
||||
if FSource.XCount > 0 then
|
||||
Result += Format('%g|', [X], fs);
|
||||
Result += Format('%g|', [X], DefSeparatorSettings);
|
||||
for i := 0 to High(XList) do
|
||||
Result += Format('%g|', [XList[i]], fs);
|
||||
Result += Format('%g|', [XList[i]], DefSeparatorSettings);
|
||||
if FSource.YCount > 0 then
|
||||
Result += Format('%g|', [Y], fs);
|
||||
Result += Format('%g|', [Y], DefSeparatorSettings);
|
||||
for i := 0 to High(YList) do
|
||||
Result += Format('%g|', [YList[i]], fs);
|
||||
Result += Format('%g|', [YList[i]], DefSeparatorSettings);
|
||||
Result += Format('%s|%s', [IntToColorHex(Color), Text]);
|
||||
end;
|
||||
end;
|
||||
@ -609,8 +606,8 @@ end;
|
||||
function TListChartSource.NewItem: PChartDataItem;
|
||||
begin
|
||||
New(Result);
|
||||
SetLength(Result^.XList, Max(XCount - 1, 0));
|
||||
SetLength(Result^.YList, Max(YCount - 1, 0));
|
||||
if XCount > 1 then SetLength(Result^.XList, XCount - 1);
|
||||
if YCount > 1 then SetLength(Result^.YList, YCount - 1);
|
||||
end;
|
||||
|
||||
procedure TListChartSource.SetColor(AIndex: Integer; AColor: TChartColor);
|
||||
@ -810,11 +807,9 @@ end;
|
||||
function CompareDataItemX(AItem1, AItem2: Pointer): Integer;
|
||||
var
|
||||
i: Integer;
|
||||
item1, item2: PChartDataItem;
|
||||
item1: PChartDataItem absolute AItem1;
|
||||
item2: PChartDataItem absolute AItem2;
|
||||
begin
|
||||
item1 := PChartDataItem(AItem1);
|
||||
item2 := PChartDataItem(AItem2);
|
||||
|
||||
Result := CompareFloat(item1^.X, item2^.X);
|
||||
if Result = 0 then
|
||||
for i := 0 to Min(High(item1^.XList), High(item2^.XList)) do begin
|
||||
@ -1489,7 +1484,7 @@ begin
|
||||
|
||||
FOriginYCount := FOrigin.YCount;
|
||||
if ReorderYList = '' then begin
|
||||
SetLength(FYOrder, FOriginYCount);
|
||||
SetLength(FYOrder, FOriginYCount);
|
||||
for i := 0 to High(FYOrder) do
|
||||
FYOrder[i] := i;
|
||||
end
|
||||
|
@ -507,6 +507,15 @@ begin
|
||||
on E: Exception do
|
||||
AssertTrue('Empty YList', E is TListChartSource.EYListEmptyError);
|
||||
end;
|
||||
AssertEquals(2, FSource.Count);
|
||||
|
||||
FSource.DataPoints.Add('1.23|2.34|3|?|t');
|
||||
AssertEquals(1.23, FSource[2]^.X);
|
||||
AssertEquals(2.34, FSource[2]^.Y);
|
||||
|
||||
FSource.DataPoints.Add('1,23|2,34|3|?|t');
|
||||
AssertEquals(1.23, FSource[3]^.X);
|
||||
AssertEquals(2.34, FSource[3]^.Y);
|
||||
|
||||
FSource.Clear;
|
||||
FSource.XCount := 2;
|
||||
|
Loading…
Reference in New Issue
Block a user