TAChart: unfortunate sorting limitation in TCustomChartSource
Original Reporter info from Mantis: Marcin Wiazowski
-
Reporter name:
Original Reporter info from Mantis: Marcin Wiazowski
- Reporter name:
Description:
TCustomChartSource introduces only a dummy sorting implementation:
function TCustomChartSource.IsSorted: Boolean;
begin
Result := false;
end;
so sorting is not defined in any way in TCustomChartSource - but IsSorted() method can be overridden in TCustomChartSource descendants.
There can exist potentially unlimited number of sorting algorithms - in particular by X, by Y, by Color (which can hold in fact any integer information), by Text, by using also XList and/or YList.
But, unfortunately, TCustomChartSource blindly assumes, that "sorting" is equal to "sorting by X". So it's not currently possible to inherit from TCustomChartSource to implement any other sorting algorithm.
So I'm attaching a tiny patch, that introduces an "IsSortedByX" protected method in TCustomChartSource. By default, "IsSortedByX" just calls "IsSorted", so everything works as usual.
But "IsSortedByX" can by overridden in descendant classes to return False, if some other (than sorting by X) algorithm is used. Thanks to that, TCustomChartSource still works properly, and any needed sorting algorithm can be implemented in descendant classes.