TAChart: Fix issues of TCalculatedChartsource related to YCount = 0 and Y value reordering.

git-svn-id: trunk@61079 -
This commit is contained in:
wp 2019-04-29 13:16:45 +00:00
parent 22bb78575c
commit 0979ae36e8
4 changed files with 20 additions and 13 deletions

View File

@ -83,9 +83,6 @@ implementation
uses
LCLIntf, Math, SysUtils;
type
TCustomChartSourceAccess = class(TCustomChartSource);
{ TCustomAnimatedChartSource }
procedure TCustomAnimatedChartSource.Changed(ASender: TObject);
@ -95,7 +92,7 @@ begin
FXCount := Origin.XCount;
FYCount := Origin.YCount;
end else begin
FXCount := MaxInt;
FXCount := MaxInt; // Allow source to be used by any series while Origin = nil
FYCount := MaxInt;
end;
Notify;
@ -104,7 +101,7 @@ end;
constructor TCustomAnimatedChartSource.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FXCount := MaxInt;
FXCount := MaxInt; // Allow source to be used by any series while Origin = nil
FYCount := MaxInt;
FListener := TListener.Create(@FOrigin, @Changed);
FTimer := TCustomTimer.Create(nil);

View File

@ -1263,6 +1263,8 @@ var
var
j: Integer;
begin
if IsEmpty then exit;
originPt := ParentChart.GraphToImage(DoublePoint(OriginX, OriginY));
fill := FFilled and (FBrush.Style <> bsClear);
SetLength(pts, Count + 1); // +1 for origin

View File

@ -469,6 +469,8 @@ var
ext: TDoubleRect;
i: Integer;
begin
if IsEmpty then exit;
with Extent do begin
ext.a := AxisToGraph(a);
ext.b := AxisToGraph(b);

View File

@ -1500,7 +1500,7 @@ begin
FSortDir := sdAscending;
FSortIndex := 0;
FSorted := false;
FXCount := MaxInt;
FXCount := MaxInt; // Allow source to be used by any series while Origin = nil
FYCount := MaxInt;
end;
@ -1548,7 +1548,7 @@ procedure TCalculatedChartSource.ExtractItem(AIndex: Integer);
function YByOrder(AOrderIndex: Integer): Double;
begin
if AOrderIndex = 0 then
if AOrderIndex <= 0 then
Result := FItem.Y
else
Result := FItem.YList[AOrderIndex - 1];
@ -1559,11 +1559,14 @@ var
i: Integer;
begin
FItem := Origin[AIndex]^;
SetLength(t, High(FYOrder));
for i := 1 to High(FYOrder) do
t[i - 1] := YByOrder(FYOrder[i]);
FItem.Y := YByOrder(FYOrder[0]);
FItem.YList := t;
if Length(FYOrder) > 0 then begin
SetLength(t, High(FYOrder));
for i := 1 to High(FYOrder) do
t[i - 1] := YByOrder(FYOrder[i]);
FItem.Y := YByOrder(FYOrder[0]);
FItem.YList := t;
end else
FItem.YList := nil;
end;
function TCalculatedChartSource.GetCount: Integer;
@ -1678,7 +1681,7 @@ var
begin
if FOrigin = nil then begin
FOriginYCount := 0;
FYCount := 0;
FYCount := MaxInt; // Allow source to be used by any series while Origin = nil
FYOrder := nil;
FItem.YList := nil;
Changed(nil);
@ -1686,6 +1689,9 @@ begin
end;
FOriginYCount := FOrigin.YCount;
if FOriginYCount = 0 then
FYOrder := nil
else
if ReorderYList = '' then begin
SetLength(FYOrder, FOriginYCount);
for i := 0 to High(FYOrder) do