TAChart: Implement sorting of TListChartsource by y value when XCount is 0. Issue #35188, patch by Marcin Wiazowski.

git-svn-id: trunk@60740 -
This commit is contained in:
wp 2019-03-20 23:26:27 +00:00
parent 29c8cde0df
commit b2a4a7868b

View File

@ -863,9 +863,28 @@ begin
end;
end;
function CompareDataItemY(AItem1, AItem2: Pointer): Integer;
var
i: Integer;
item1: PChartDataItem absolute AItem1;
item2: PChartDataItem absolute AItem2;
begin
Result := CompareFloat(item1^.Y, item2^.Y);
if Result = 0 then
for i := 0 to Min(High(item1^.YList), High(item2^.YList)) do begin
Result := CompareFloat(item1^.YList[i], item2^.YList[i]);
if Result <> 0 then
exit;
end;
end;
procedure TListChartSource.Sort;
begin
FData.Sort(@CompareDataItemX);
if XCount > 0 then
FData.Sort(@CompareDataItemX)
else
if YCount > 0 then
FData.Sort(@CompareDataItemY);
end;
procedure TListChartSource.UpdateCachesAfterAdd(AX, AY: Double);