TAChart: Code cleanups and bugfixes (bugfixes by Uwe Zimmermann and Oled), bug #10699

git-svn-id: trunk@13877 -
This commit is contained in:
vincents 2008-01-25 14:45:02 +00:00
parent cc9541e07c
commit 675e3bee30
3 changed files with 23 additions and 51 deletions

View File

@ -44,6 +44,7 @@ Installation
Changes Changes
------- -------
* 25/01/2008 - Code cleanups and bugfixes (bugfixes by Uwe Zimmermann and Oled)
* 22/01/2008 - Implemented ZoomFull, PaintOnCanvas and slight modifications to add TSerie pen style (by oleg) * 22/01/2008 - Implemented ZoomFull, PaintOnCanvas and slight modifications to add TSerie pen style (by oleg)
* 27/09/2007 - Bugfixes and partially implemented multibar in TBarSeries * 27/09/2007 - Bugfixes and partially implemented multibar in TBarSeries
* 29/08/2007 - Bugfixes and implement Bug fixes SaveToBitmapFile * 29/08/2007 - Bugfixes and implement Bug fixes SaveToBitmapFile

View File

@ -712,7 +712,7 @@ var
begin begin
if Maxi>59 then Sleep(1); if Maxi>59 then Sleep(1);
Etendue:=Maxi-Mini; Etendue:=Maxi-Mini;
if Etendue=0 then begin Debut:=Mini; Pas:=1; Exit; end; if Etendue<=0 then begin Debut:=Mini; Pas:=1; Exit; end;
Mult[1]:=1; Mult[1]:=1;
EtendueTmp:=Etendue; EtendueTmp:=Etendue;
NbPas[1]:=EtendueTmp; NbPas[1]:=EtendueTmp;
@ -991,8 +991,8 @@ End;
procedure TChart.PaintOnCanvas(ACanvas : TCanvas; ARect : TRect); procedure TChart.PaintOnCanvas(ACanvas : TCanvas; ARect : TRect);
var i: integer; var i: integer;
begin begin
YImageMin:={Height-20}ARect.Bottom-5; YImageMin:=ARect.Bottom-5;
YImageMax:={5}ARect.Top+5; YImageMax:=ARect.Top+5;
if FTitle.Visible then begin if FTitle.Visible then begin
TmpFont.Assign( ACanvas.Font ); TmpFont.Assign( ACanvas.Font );
@ -1018,14 +1018,14 @@ begin
-ACanvas.TextHeight('1'); -ACanvas.TextHeight('1');
end; end;
if FMirrorX then begin if FMirrorX then begin
XImageMin:={Width-YMarkWidth-GetLegendWidth}ARect.Right-YMarkWidth-GetLegendWidth(ACanvas); XImageMin:=ARect.Right-YMarkWidth-GetLegendWidth(ACanvas);
XImageMax:={10}ARect.Left; XImageMax:=ARect.Left;
end else begin end else begin
if FLeftAxis.Visible and FAxisVisible then if FLeftAxis.Visible and FAxisVisible then
XImageMin:=YMarkWidth+ACanvas.TextHeight(FLeftAxis.Title.Caption)+ARect.Left XImageMin:=YMarkWidth+ACanvas.TextHeight(FLeftAxis.Title.Caption)+ARect.Left
else else
XImageMin:=YMarkWidth+ARect.Left; XImageMin:=YMarkWidth+ARect.Left;
XImageMax:={Width-10-GetLegendWidth}ARect.Right-10-GetLegendWidth(ACanvas); XImageMax:=ARect.Right-10-GetLegendWidth(ACanvas);
end; end;
Refresh(ACanvas, ARect); Refresh(ACanvas, ARect);
end; end;
@ -1037,7 +1037,6 @@ begin
ACanvas.Pen.Color:=Color; ACanvas.Pen.Color:=Color;
ACanvas.Brush.Color:=Color; ACanvas.Brush.Color:=Color;
ACanvas.Brush.Style:=bsSolid; ACanvas.Brush.Style:=bsSolid;
// ACanvas.Rectangle(0,0,Width,Height);
ACanvas.Rectangle(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom); ACanvas.Rectangle(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom);
end; end;
@ -1055,7 +1054,7 @@ begin
for i := 0 to FTitle.Text.Count -1 do begin for i := 0 to FTitle.Text.Count -1 do begin
case FTitle.Alignment of case FTitle.Alignment of
taLeftJustify: xpos := XImageMin; taLeftJustify: xpos := XImageMin;
taCenter: xpos := ({Width}ARect.Left+ARect.Right-ACanvas.TextWidth(FTitle.Text[i])) div 2; taCenter: xpos := (ARect.Left+ARect.Right-ACanvas.TextWidth(FTitle.Text[i])) div 2;
taRightJustify: xpos := XImageMax - ACanvas.TextWidth(FTitle.Text[i]); taRightJustify: xpos := XImageMax - ACanvas.TextWidth(FTitle.Text[i]);
end; end;
ACanvas.TextOut( xpos ,t,FTitle.Text[i]); ACanvas.TextOut( xpos ,t,FTitle.Text[i]);
@ -1069,11 +1068,11 @@ begin
TmpFont.Assign( ACanvas.Font ); TmpFont.Assign( ACanvas.Font );
ACanvas.Brush.Assign( FFoot.Brush ); ACanvas.Brush.Assign( FFoot.Brush );
ACanvas.Font.Assign( FFoot.Font ); ACanvas.Font.Assign( FFoot.Font );
t := {Height}ARect.Bottom-5-ACanvas.TextHeight(FFoot.Text[0]); t := ARect.Bottom-5-ACanvas.TextHeight(FFoot.Text[0]);
for i := FFoot.Text.Count - 1 downto 0 do begin for i := FFoot.Text.Count - 1 downto 0 do begin
case FFoot.Alignment of case FFoot.Alignment of
taLeftJustify: xpos := XImageMin; taLeftJustify: xpos := XImageMin;
taCenter: xpos := ({Width}ARect.Left+ARect.Right-ACanvas.TextWidth(FFoot.Text[i])) div 2; taCenter: xpos := (ARect.Left+ARect.Right-ACanvas.TextWidth(FFoot.Text[i])) div 2;
taRightJustify: xpos := XImageMax - ACanvas.TextWidth(FFoot.Text[i]); taRightJustify: xpos := XImageMax - ACanvas.TextWidth(FFoot.Text[i]);
end; end;
ACanvas.TextOut( xpos ,t,FFoot.Text[i]); ACanvas.TextOut( xpos ,t,FFoot.Text[i]);
@ -1149,12 +1148,12 @@ begin
if MaxLargTexte+LeftAxisWidth>YMarkWidth then begin if MaxLargTexte+LeftAxisWidth>YMarkWidth then begin
YMarkWidth:=MaxLargTexte+LeftAxisWidth; YMarkWidth:=MaxLargTexte+LeftAxisWidth;
if FMirrorX then begin if FMirrorX then begin
XImageMin:={Width-YMarkWidth-GetLegendWidth(ACanvas)}ARect.Right-YMarkWidth-GetLegendWidth(ACanvas); XImageMin:=ARect.Right-YMarkWidth-GetLegendWidth(ACanvas);
XImageMax:={10}ARect.Left+10; XImageMax:=ARect.Left+10;
end end
else begin else begin
XImageMin:={YMarkWidth}ARect.Left+YMarkWidth; XImageMin:=ARect.Left+YMarkWidth;
XImageMax:={Width-10-GetLegendWidth}ARect.Right-10-GetLegendWidth(ACanvas); XImageMax:=ARect.Right-10-GetLegendWidth(ACanvas);
end; end;
// Update coefs // Update coefs
@ -1210,7 +1209,7 @@ begin
{ Canvas.Brush.Color:=Color; { Canvas.Brush.Color:=Color;
Canvas.Font.Color:=clBlack; Canvas.Font.Color:=clBlack;
} }
if FMirrorX then T := {Width}ARect.Right-ACanvas.TextWidth(FLeftAxis.Title.Caption)+5 if FMirrorX then T := ARect.Right-ACanvas.TextWidth(FLeftAxis.Title.Caption)+5
else T := 5; else T := 5;
if FTitle.Visible then if FTitle.Visible then
RotateLabel(ACanvas, T, YImageMin+((YImageMax-YImageMin) div 2) RotateLabel(ACanvas, T, YImageMin+((YImageMax-YImageMin) div 2)
@ -1262,7 +1261,7 @@ begin
LargTexte:=ACanvas.TextWidth(MyText) div 2; LargTexte:=ACanvas.TextWidth(MyText) div 2;
XPos:=XTemp-LargTexte; XPos:=XTemp-LargTexte;
if XPos<1 then Xpos:=1; if XPos<1 then Xpos:=1;
if XPos+LargTexte*2>{Width}ARect.Right then Xpos:={Width}ARect.Right-LargTexte*2-1; if XPos+LargTexte*2>ARect.Right then Xpos:=ARect.Right-LargTexte*2-1;
ACanvas.TextOut(Xpos,YImageMin+4,MyText); ACanvas.TextOut(Xpos,YImageMin+4,MyText);
end; end;
Marque:=Marque+Pas; Marque:=Marque+Pas;
@ -1293,7 +1292,7 @@ begin
LargTexte:=ACanvas.TextWidth(MyText) div 2; LargTexte:=ACanvas.TextWidth(MyText) div 2;
XPos:=XTemp-LargTexte; XPos:=XTemp-LargTexte;
if XPos<1 then Xpos:=1; if XPos<1 then Xpos:=1;
if XPos+LargTexte*2>{Width}ARect.Right then Xpos:={Width}ARect.Right-LargTexte*2-1; if XPos+LargTexte*2>ARect.Right then Xpos:=ARect.Right-LargTexte*2-1;
ACanvas.TextOut(Xpos,YImageMin+4,MyText); ACanvas.TextOut(Xpos,YImageMin+4,MyText);
end; end;
Marque:=Marque-Pas; Marque:=Marque-Pas;
@ -1403,7 +1402,7 @@ begin
end else begin end else begin
h:=5+SeriesInLegendCount*(TH+5); h:=5+SeriesInLegendCount*(TH+5);
end; end;
x1 := {Width-w-5}ARect.Right-w-5; x1 := ARect.Right-w-5;
y1 := YImageMax; y1 := YImageMax;
x2 := x1+w; x2 := x1+w;
y2 := y1+h; y2 := y1+h;
@ -1691,13 +1690,13 @@ begin
// Image coordinates calculation // Image coordinates calculation
// Update max in graph // Update max in graph
// If one point : +/-10% of the point coordinates // If one point : +/-10% of the point coordinates
Tolerance:=0.001; //LUIS ISTO e' o EXTRA Tolerance:=0.001; //this should be cleaned eventually
// Tolerance:=0.1; //LUIS ISTO e' o EXTRA // Tolerance:=0.1;
if NBPointsMax > 0 then if NBPointsMax > 0 then
// If several points : automatic +/-10% of interval // If several points : automatic +/-10% of interval
begin begin
Valeur:=Tolerance*(XMaxSeries-XMinSeries); //podemos acabar c esta tolerancia Valeur:=Tolerance*(XMaxSeries-XMinSeries);
if Valeur<>0 then if Valeur<>0 then
begin begin
if FAutoUpdateXMin then FXGraphMin:=XMinSeries-Valeur; if FAutoUpdateXMin then FXGraphMin:=XMinSeries-Valeur;
@ -1846,12 +1845,7 @@ end;
procedure TChart.DrawOnCanvas(Rect : TRect; ACanvas : TCanvas); procedure TChart.DrawOnCanvas(Rect : TRect; ACanvas : TCanvas);
var tmpCanvas : TCanvas; var tmpCanvas : TCanvas;
Begin Begin
{TmpCanvas:=Canvas; PaintOnCanvas(ACanvas,Rect);
Canvas:=ACanvas;
Refresh;}
PaintOnCanvas(ACanvas,Rect);
{Canvas:=TmpCanvas;}
//ACanvas.CopyRect(Rect, Canvas, Rect);
End; End;

View File

@ -87,7 +87,6 @@ type
function Add(aValue: Double; XLabel: String; Color: TColor) : Longint; virtual; function Add(aValue: Double; XLabel: String; Color: TColor) : Longint; virtual;
procedure Delete(Index:Integer); virtual; procedure Delete(Index:Integer); virtual;
procedure Clear; procedure Clear;
// function AddY(X, Y: Double; XLabel: String; Color: TColor) : Longint;
property Coord: TList read FCoordList; property Coord: TList read FCoordList;
published published
@ -117,7 +116,6 @@ type
public public
Constructor Create(AOwner:TChartSeries); Constructor Create(AOwner:TChartSeries);
Destructor Destroy; override; Destructor Destroy; override;
// Procedure Draw(px,py:Integer; ColorValue:TColor; AStyle:TSeriesPointerStyle);
Procedure Draw(ACanvas : TCanvas; px,py:Integer; SeriesColor: TColor); Procedure Draw(ACanvas : TCanvas; px,py:Integer; SeriesColor: TColor);
property ParentSeries:TChartSeries read FOwner; property ParentSeries:TChartSeries read FOwner;
@ -368,9 +366,8 @@ begin
i := 0; i := 0;
while (i < FCoordList.Count) and (PChartCoord(FCoordList.Items[i])^.x <= X) do inc(i); while (i < FCoordList.Count) and (PChartCoord(FCoordList.Items[i])^.x <= X) do inc(i);
if i = FCoordList.Count then FCoordList.Add(Coordn) if i = FCoordList.Count then FCoordList.Add(Coordn)
else FCoordList.Insert(I+1, Coordn); else FCoordList.Insert(i, Coordn);
// FCoordList.Add(Coord);
result := FCoordList.IndexOf( Coordn ); result := FCoordList.IndexOf( Coordn );
end; end;
@ -1108,20 +1105,6 @@ end;
constructor TBarSeries.Create(AOwner:TComponent); constructor TBarSeries.Create(AOwner:TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
@ -1283,14 +1266,8 @@ begin
end; end;
end; end;
end; end;
constructor TPieSeries.Create(AOwner:TComponent); constructor TPieSeries.Create(AOwner:TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);