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

View File

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

View File

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

View File

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