mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:59:20 +02:00
applied reformatting patch from Alexander Klenin
http://bugs.freepascal.org/view.php?id=12577 git-svn-id: trunk@17252 -
This commit is contained in:
parent
417bfc48d5
commit
101d1a7688
@ -37,7 +37,8 @@ uses
|
||||
{$ENDIF}
|
||||
classes, graphics, tagraph, taengine, sysutils, dialogs;
|
||||
|
||||
Const clTAColor = clScrollBar;
|
||||
const
|
||||
clTAColor = clScrollBar;
|
||||
|
||||
type
|
||||
|
||||
@ -49,7 +50,8 @@ type
|
||||
PChartCoord = ^ChartCoord;
|
||||
|
||||
TSeriesPointerStyle = (
|
||||
psRectangle,psCircle,psCross,psDiagCross,psStar,psLowBracket,psHighBracket);
|
||||
psRectangle, psCircle, psCross, psDiagCross, psStar,
|
||||
psLowBracket, psHighBracket);
|
||||
|
||||
BarException = class(Exception);
|
||||
|
||||
@ -85,7 +87,7 @@ type
|
||||
|
||||
function Count: Integer;
|
||||
function AddXY(X, Y: Double; XLabel: String; Color: TColor): Longint; virtual;
|
||||
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 Clear;
|
||||
|
||||
@ -98,8 +100,7 @@ type
|
||||
|
||||
TSeriesPointer = class(TPersistent)
|
||||
private
|
||||
FHorizSize,
|
||||
FVertSize:Integer;
|
||||
FHorizSize, FVertSize: Integer;
|
||||
FStyle: TSeriesPointerStyle;
|
||||
FPen: TChartPen;
|
||||
FBrush: TBrush;
|
||||
@ -107,44 +108,41 @@ type
|
||||
FOwner: TChartSeries;
|
||||
FChanged: TNotifyEvent;
|
||||
|
||||
Procedure SetVisible(Value:Boolean);
|
||||
Procedure SetStyle(Value:TSeriesPointerStyle);
|
||||
Procedure SetPen(Value:TChartPen);
|
||||
Procedure SetBrush(Value:TBrush);
|
||||
Procedure SetHorizSize(Value:Integer);
|
||||
Procedure SetVertSize(Value:Integer);
|
||||
procedure SetVisible(Value: Boolean);
|
||||
procedure SetStyle(Value: TSeriesPointerStyle);
|
||||
procedure SetPen(Value: TChartPen);
|
||||
procedure SetBrush(Value: TBrush);
|
||||
procedure SetHorizSize(Value: Integer);
|
||||
procedure SetVertSize(Value: Integer);
|
||||
protected
|
||||
public
|
||||
Constructor Create(AOwner:TChartSeries);
|
||||
Destructor Destroy; override;
|
||||
Procedure Draw(ACanvas : TCanvas; px,py:Integer; SeriesColor: TColor);
|
||||
constructor Create(AOwner: TChartSeries);
|
||||
destructor Destroy; override;
|
||||
procedure Draw(ACanvas: TCanvas; px, py: Integer; SeriesColor: TColor);
|
||||
|
||||
property ParentSeries: TChartSeries read FOwner;
|
||||
Procedure Assign(Source:TPersistent); override;
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
published
|
||||
property Brush: TBrush read FBrush write SetBrush;
|
||||
property Pen: TChartPen read FPen write SetPen;
|
||||
Property Style:TSeriesPointerStyle read FStyle write SetStyle;
|
||||
Property Visible:Boolean read FVisible write SetVisible;
|
||||
property Style: TSeriesPointerStyle read FStyle write SetStyle;
|
||||
property Visible: Boolean read FVisible write SetVisible;
|
||||
property OnChange: TNotifyEvent read FChanged write FChanged;
|
||||
property HorizSize: Integer read FHorizSize write SetHorizSize default 4;
|
||||
property VertSize: Integer read FVertSize write SetVertSize default 4;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
TLineStyle = (lsVertical, lsHorizontal);
|
||||
|
||||
TBarSeries = class(TChartSeries)
|
||||
private
|
||||
FBarBrush: TBrush;
|
||||
FBarPen: TPen;
|
||||
|
||||
FBarWidthPercent: Integer;
|
||||
|
||||
FSeriesNumber: Integer;
|
||||
|
||||
Procedure SetBarWidthPercent(Value:Integer);
|
||||
procedure SetBarWidthPercent(Value: Integer);
|
||||
procedure SetBarBrush(Value: TBrush);
|
||||
procedure SetBarPen(Value: TPen);
|
||||
protected
|
||||
@ -156,7 +154,6 @@ type
|
||||
{from parent}
|
||||
procedure Draw(ACanvas: TCanvas); override;
|
||||
function AddXY(X, Y: Double; XLabel: String; Color: TColor): Longint; override;
|
||||
// function AddBar(Value: Double; Text: String; Color: TColor) : Longint;
|
||||
published
|
||||
property BarWidthPercent:Integer read FBarWidthPercent write SetBarWidthPercent default 70;
|
||||
property BarBrush: TBrush read FBarBrush write SetBarBrush;
|
||||
@ -169,7 +166,6 @@ type
|
||||
TPieSeries = class(TChartSeries)
|
||||
private
|
||||
ColorIndex: Integer;
|
||||
|
||||
FPiePen: TPen;
|
||||
procedure SetPiePen(Value: TPen);
|
||||
protected
|
||||
@ -188,22 +184,16 @@ type
|
||||
property Active;
|
||||
end;
|
||||
|
||||
|
||||
TAreaSeries = class(TChartSeries)
|
||||
private
|
||||
{ ColorIndex: Integer;
|
||||
|
||||
FPiePen: TPen;
|
||||
procedure SetPiePen(Value:TPen);
|
||||
}
|
||||
FAreaLinesPen: TChartPen;
|
||||
FAreaBrush: TBrush;
|
||||
FStairs: boolean;
|
||||
FInvertedStairs: boolean;
|
||||
FStairs: Boolean;
|
||||
FInvertedStairs: Boolean;
|
||||
|
||||
procedure SetAreaBrush(value: TBrush);
|
||||
procedure SetStairs(value: Boolean);
|
||||
procedure SetInvertedStairs(value: Boolean);
|
||||
procedure SetAreaBrush(Value: TBrush);
|
||||
procedure SetStairs(Value: Boolean);
|
||||
procedure SetInvertedStairs(Value: Boolean);
|
||||
protected
|
||||
procedure StyleChanged(Sender: TObject);
|
||||
public
|
||||
@ -216,15 +206,12 @@ type
|
||||
published
|
||||
property AreaLinesPen: TChartPen read FAreaLinesPen write FAreaLinesPen;
|
||||
property AreaBrush: TBrush read FAreaBrush write SetAreaBrush;
|
||||
property Stairs: boolean read FStairs write setStairs;
|
||||
property InvertedStairs: boolean read FInvertedStairs write setInvertedStairs;
|
||||
property Stairs: boolean read FStairs write SetStairs;
|
||||
property InvertedStairs: boolean read FInvertedStairs write SetInvertedStairs;
|
||||
property Title;
|
||||
property Active;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
TSerie = class(TChartSeries)
|
||||
private
|
||||
FPointer: TSeriesPointer;
|
||||
@ -232,16 +219,12 @@ type
|
||||
XOfYGraphMin, XOfYGraphMax: Double; // X max value of points
|
||||
FShowPoints: Boolean;
|
||||
FShowLines: Boolean;
|
||||
|
||||
UpdateInProgress: Boolean;
|
||||
|
||||
procedure SetShowPoints(Value: Boolean);
|
||||
procedure SetShowLines(Value: Boolean);
|
||||
procedure SetPointer(Value: TSeriesPointer);
|
||||
protected
|
||||
{ Déclarations protégées }
|
||||
public
|
||||
|
||||
{ Déclarations publiques }
|
||||
FStyle: TPenStyle;
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@ -261,7 +244,7 @@ type
|
||||
function GetXMax: Double;
|
||||
function GetYMin: Double;
|
||||
function GetYMax: Double;
|
||||
procedure SetColor(Index:Integer;_Color:TColor);
|
||||
procedure SetColor(Index: Integer; AColor: TColor);
|
||||
function GetColor(Index: Integer): TColor;
|
||||
|
||||
procedure BeginUpdate;
|
||||
@ -276,7 +259,7 @@ type
|
||||
property Active;
|
||||
|
||||
property ShowPoints: Boolean read FShowPoints write SetShowPoints;
|
||||
property ShowLines:Boolean read FShowLines write SetShowLines default True;
|
||||
property ShowLines: Boolean read FShowLines write SetShowLines default true;
|
||||
property Pointer: TSeriesPointer read FPointer write SetPointer;
|
||||
end;
|
||||
|
||||
@ -292,10 +275,7 @@ type
|
||||
procedure SetPos(Value: Double);
|
||||
procedure SetPen(Value: TPen);
|
||||
procedure SetStyle(Value: TLineStyle);
|
||||
protected
|
||||
{ Déclarations protégées }
|
||||
public
|
||||
{ Déclarations publiques }
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
@ -303,21 +283,14 @@ type
|
||||
procedure StyleChanged(Sender:TObject);
|
||||
|
||||
property LineStyle: TLineStyle read FStyle write SetStyle;
|
||||
|
||||
published
|
||||
property Pen: TPen read FPen write SetPen;
|
||||
property Position: Double read PosGraph write SetPos;
|
||||
property Active;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
constructor TChartSeries.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
@ -327,18 +300,18 @@ begin
|
||||
XGraphMax := MinDouble;
|
||||
YGraphMax := MinDouble;
|
||||
|
||||
FActive := True;
|
||||
FShowInLegend := True;
|
||||
FActive := true;
|
||||
FShowInLegend := true;
|
||||
FMarks := smsLabel;
|
||||
FCoordList := TList.Create;
|
||||
end;
|
||||
|
||||
destructor TChartSeries.Destroy;
|
||||
var i: integer;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to FCoordList.Count - 1 do begin
|
||||
for i := 0 to FCoordList.Count - 1 do
|
||||
Dispose(PChartCoord(FCoordList.Items[i]));
|
||||
end;
|
||||
FCoordList.Free;
|
||||
|
||||
inherited Destroy;
|
||||
@ -346,40 +319,43 @@ end;
|
||||
|
||||
function TChartSeries.GetXMinVal: Integer;
|
||||
begin
|
||||
if count > 0 then
|
||||
result := round(PChartCoord(FCoordList[FCoordList.Count-1])^.x)
|
||||
else result := 0;
|
||||
if Count > 0 then
|
||||
Result := Round(PChartCoord(FCoordList[FCoordList.Count-1])^.x)
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TChartSeries.AddXY(X, Y: Double; XLabel: String; Color: TColor): Longint;
|
||||
var
|
||||
coordn: PChartCoord;
|
||||
i: integer;
|
||||
i: Integer;
|
||||
begin
|
||||
//save the coord and color
|
||||
New(Coordn);
|
||||
Coordn^.x := X;
|
||||
Coordn^.y := Y;
|
||||
Coordn^.Color := Color;
|
||||
Coordn^.Text := XLabel;
|
||||
New(coordn);
|
||||
coordn^.x := X;
|
||||
coordn^.y := Y;
|
||||
coordn^.Color := Color;
|
||||
coordn^.Text := XLabel;
|
||||
|
||||
//add in order or at end
|
||||
i := 0;
|
||||
while (i < FCoordList.Count) and (PChartCoord(FCoordList.Items[i])^.x <= X) do inc(i);
|
||||
if i = FCoordList.Count then FCoordList.Add(Coordn)
|
||||
else FCoordList.Insert(i, Coordn);
|
||||
while (i < FCoordList.Count) and (PChartCoord(FCoordList.Items[i])^.x <= X) do
|
||||
Inc(i);
|
||||
if i = FCoordList.Count then FCoordList.Add(coordn)
|
||||
else FCoordList.Insert(i, coordn);
|
||||
|
||||
result := FCoordList.IndexOf( Coordn );
|
||||
Result := FCoordList.IndexOf(coordn);
|
||||
end;
|
||||
|
||||
function TChartSeries.Add(aValue: Double; XLabel: String; Color: TColor) : Longint;
|
||||
var XVal: Integer;
|
||||
function TChartSeries.Add(AValue: Double; XLabel: String; Color: TColor): Longint;
|
||||
var
|
||||
XVal: Integer;
|
||||
begin
|
||||
if FCoordList.Count = 0 then
|
||||
XVal := 0
|
||||
else
|
||||
XVal := Round(PChartCoord(FCoordList.Items[ FCoordList.Count-1 ])^.x);
|
||||
AddXY(XVal+1, aValue, XLabel, Color);
|
||||
AddXY(XVal + 1, AValue, XLabel, Color);
|
||||
end;
|
||||
|
||||
|
||||
@ -404,7 +380,7 @@ end;
|
||||
|
||||
function TChartSeries.Count:Integer;
|
||||
begin
|
||||
Result := FCoordList.count;
|
||||
Result := FCoordList.Count;
|
||||
end;
|
||||
|
||||
procedure TChartSeries.SetActive(Value: Boolean);
|
||||
@ -425,47 +401,45 @@ begin
|
||||
if ParentChart <> nil then ParentChart.Invalidate;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Procedure TSeriesPointer.SetVisible(Value:Boolean);
|
||||
procedure TSeriesPointer.SetVisible(Value: Boolean);
|
||||
begin
|
||||
FVisible := Value;
|
||||
if assigned( FChanged ) then FChanged(Self);
|
||||
if Assigned(FChanged) then FChanged(Self);
|
||||
end;
|
||||
|
||||
Procedure TSeriesPointer.SetStyle(Value:TSeriesPointerStyle);
|
||||
procedure TSeriesPointer.SetStyle(Value: TSeriesPointerStyle);
|
||||
begin
|
||||
FStyle := Value;
|
||||
if assigned( FChanged ) then FChanged(Self);
|
||||
if Assigned(FChanged) then FChanged(Self);
|
||||
end;
|
||||
|
||||
Procedure TSeriesPointer.SetPen(Value:TChartPen);
|
||||
procedure TSeriesPointer.SetPen(Value: TChartPen);
|
||||
begin
|
||||
FPen.Assign(Value);
|
||||
if assigned( FChanged ) then FChanged(Self);
|
||||
if Assigned(FChanged) then FChanged(Self);
|
||||
end;
|
||||
|
||||
Procedure TSeriesPointer.SetBrush(Value:TBrush);
|
||||
procedure TSeriesPointer.SetBrush(Value: TBrush);
|
||||
begin
|
||||
FBrush.Assign(Value);
|
||||
if assigned( FChanged ) then FChanged(Self);
|
||||
if Assigned(FChanged) then FChanged(Self);
|
||||
end;
|
||||
|
||||
Procedure TSeriesPointer.SetHorizSize(Value:Integer);
|
||||
Begin
|
||||
procedure TSeriesPointer.SetHorizSize(Value: Integer);
|
||||
begin
|
||||
FHorizSize := Value;
|
||||
if assigned( FChanged ) then FChanged(Self);
|
||||
if Assigned(FChanged) then FChanged(Self);
|
||||
end;
|
||||
|
||||
Procedure TSeriesPointer.SetVertSize(Value:Integer);
|
||||
Begin
|
||||
procedure TSeriesPointer.SetVertSize(Value: Integer);
|
||||
begin
|
||||
FVertSize := Value;
|
||||
if assigned( FChanged ) then FChanged(Self);
|
||||
if Assigned(FChanged) then FChanged(Self);
|
||||
end;
|
||||
|
||||
Constructor TSeriesPointer.Create(AOwner:TChartSeries);
|
||||
constructor TSeriesPointer.Create(AOwner: TChartSeries);
|
||||
begin
|
||||
FBrush := TBrush.Create;
|
||||
FBrush.Color := clLime;
|
||||
@ -476,14 +450,14 @@ begin
|
||||
FVertSize := 4;
|
||||
end;
|
||||
|
||||
Destructor TSeriesPointer.Destroy;
|
||||
destructor TSeriesPointer.Destroy;
|
||||
begin
|
||||
FBrush.Free;
|
||||
FPen.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
Procedure TSeriesPointer.Draw(ACanvas : TCanvas; px,py:Integer; SeriesColor: TColor);
|
||||
procedure TSeriesPointer.Draw(ACanvas: TCanvas; px, py: Integer; SeriesColor: TColor);
|
||||
begin
|
||||
with FOwner do begin
|
||||
ACanvas.Brush.Assign(FBrush);
|
||||
@ -542,7 +516,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TSeriesPointer.Assign(Source:TPersistent);
|
||||
procedure TSeriesPointer.Assign(Source: TPersistent);
|
||||
begin
|
||||
if Source is TSeriesPointer then
|
||||
with TSeriesPointer(Source) do begin
|
||||
@ -554,10 +528,7 @@ begin
|
||||
inherited Assign(Source);
|
||||
end;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
constructor TSerie.Create(AOwner: TComponent);
|
||||
begin
|
||||
@ -569,10 +540,10 @@ begin
|
||||
|
||||
FStyle := psSolid;
|
||||
|
||||
ShowPoints:=False;
|
||||
ShowLines:=True;
|
||||
ShowPoints := false;
|
||||
ShowLines := true;
|
||||
|
||||
UpdateInProgress:=False;
|
||||
UpdateInProgress := false;
|
||||
end;
|
||||
|
||||
destructor TSerie.Destroy;
|
||||
@ -594,12 +565,10 @@ end;
|
||||
procedure TSerie.Draw(ACanvas: TCanvas);
|
||||
var
|
||||
i, j: Integer;
|
||||
|
||||
xi1, yi1, xi2, yi2: Integer;
|
||||
xg1, yg1, xg2, yg2: Double;
|
||||
Min, Max, a, b: Double;
|
||||
Inside1, Inside2: Boolean;
|
||||
Chart1:TChart;
|
||||
YLeft, YRight, XBottom, XTop: Double;
|
||||
XLine, YLine: array[1..2] of Integer;
|
||||
BLeft, BRight, BBottom, BTop: Boolean;
|
||||
@ -611,7 +580,7 @@ var
|
||||
|
||||
label Points;
|
||||
begin
|
||||
if count=0 then Exit;
|
||||
if Count = 0 then exit;
|
||||
|
||||
with ParentChart do begin
|
||||
XMin := XImageMin;
|
||||
@ -638,8 +607,7 @@ begin
|
||||
Min := ParentChart.XGraphMin;
|
||||
Max := ParentChart.XGraphMax;
|
||||
|
||||
|
||||
for i:=0 to count-2 do begin
|
||||
for i := 0 to Count - 2 do begin
|
||||
graphCoord := FCoordList.Items[i];
|
||||
xg1 := graphCoord^.x;
|
||||
yg1 := graphCoord^.y;
|
||||
@ -649,7 +617,6 @@ begin
|
||||
yg2 := graphCoord^.y;
|
||||
ParentChart.GraphToImage(xg2, yg2, xi2, yi2);
|
||||
|
||||
|
||||
ACanvas.Pen.Style := FStyle;
|
||||
ACanvas.Pen.Color := graphCoord^.Color;
|
||||
|
||||
@ -662,8 +629,10 @@ begin
|
||||
goto Points;
|
||||
end;
|
||||
|
||||
if ((xg1<ParentChart.XGraphMin) and (xg2<ParentChart.XGraphMin)) or ((xg1>ParentChart.XGraphMax) and (xg2>ParentChart.XGraphMax)) or
|
||||
((yg1<ParentChart.YGraphMin) and (yg2<ParentChart.YGraphMin)) or ((yg1>ParentChart.YGraphMax) and (yg2>ParentChart.YGraphMax)) then
|
||||
if
|
||||
((xg1<ParentChart.XGraphMin) and (xg2<ParentChart.XGraphMin)) or ((xg1>ParentChart.XGraphMax) and (xg2>ParentChart.XGraphMax)) or
|
||||
((yg1<ParentChart.YGraphMin) and (yg2<ParentChart.YGraphMin)) or ((yg1>ParentChart.YGraphMax) and (yg2>ParentChart.YGraphMax))
|
||||
then
|
||||
goto Points;
|
||||
|
||||
if yg1 > yg2 then begin
|
||||
@ -770,30 +739,31 @@ begin
|
||||
|
||||
ACanvas.MoveTo(xi1, yi1);
|
||||
ACanvas.LineTo(xi2, yi2);
|
||||
|
||||
end;
|
||||
|
||||
end;
|
||||
end; // if FShowLines
|
||||
|
||||
Points:
|
||||
if FShowPoints and (yi1>=YMin) and (yi1<=YMax)
|
||||
and (xi1>=XMin) and (xi1<=XMax) then begin
|
||||
if
|
||||
FShowPoints and
|
||||
(yi1 >= YMin) and (yi1 <= YMax) and
|
||||
(xi1 >= XMin) and (xi1 <= XMax)
|
||||
then
|
||||
FPointer.Draw(ACanvas, xi1, yi1, SeriesColor);
|
||||
end;
|
||||
|
||||
end;
|
||||
end; // for
|
||||
|
||||
// Draw last point
|
||||
graphCoord := FCoordList.items[ Count - 1 ];
|
||||
graphCoord := FCoordList.Items[Count - 1];
|
||||
xg1 := graphCoord^.x;
|
||||
yg1 := graphCoord^.y;
|
||||
ParentChart.GraphToImage(xg1, yg1, xi1, yi1);
|
||||
|
||||
if FShowPoints and (yi1>=YMin) and
|
||||
(yi1<=YMax) and (xi1>=XMin) and (xi1<=XMax) then begin
|
||||
if
|
||||
FShowPoints and
|
||||
(yi1 >= YMin) and (yi1 <= YMax) and
|
||||
(xi1 >= XMin) and (xi1 <= XMax)
|
||||
then
|
||||
FPointer.draw(ACanvas, xi1, yi1, SeriesColor);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TSerie.AddXY(X, Y: Double; XLabel: String; Color: TColor): Longint;
|
||||
@ -833,7 +803,7 @@ var
|
||||
i: Integer;
|
||||
Val: Double;
|
||||
begin
|
||||
if not(UpdateInProgress) then begin
|
||||
if not UpdateInProgress then begin
|
||||
if Value < XGraphMin then XGraphMin := Value
|
||||
else if Value > XGraphMax then XGraphMax := Value
|
||||
else begin
|
||||
@ -870,7 +840,7 @@ var
|
||||
i: Integer;
|
||||
Val: Double;
|
||||
begin
|
||||
if not(UpdateInProgress) then begin
|
||||
if not UpdateInProgress then begin
|
||||
if Value<YGraphMin then YGraphMin:=Value
|
||||
else if Value>YGraphMax then YGraphMax:=Value
|
||||
else begin
|
||||
@ -945,14 +915,14 @@ begin
|
||||
Y := YGraphMin;
|
||||
end;
|
||||
|
||||
procedure TSerie.SetColor(Index:Integer;_Color:TColor);
|
||||
procedure TSerie.SetColor(Index: Integer; AColor: TColor);
|
||||
begin
|
||||
PChartCoord(FCoordList.items[Index])^.color := _Color;
|
||||
PChartCoord(FCoordList.items[Index])^.Color := AColor;
|
||||
end;
|
||||
|
||||
function TSerie.GetColor(Index: Integer): TColor;
|
||||
begin
|
||||
result := PChartCoord(FCoordList.items[Index])^.color;
|
||||
Result := PChartCoord(FCoordList.items[Index])^.Color;
|
||||
end;
|
||||
|
||||
procedure TSerie.SetShowPoints(Value: Boolean);
|
||||
@ -969,7 +939,7 @@ end;
|
||||
|
||||
procedure TSerie.BeginUpdate;
|
||||
begin
|
||||
UpdateInProgress:=True;
|
||||
UpdateInProgress := true;
|
||||
end;
|
||||
|
||||
procedure TSerie.EndUpdate;
|
||||
@ -977,7 +947,7 @@ var
|
||||
i: Integer;
|
||||
Val: Double;
|
||||
begin
|
||||
UpdateInProgress:=False;
|
||||
UpdateInProgress := false;
|
||||
|
||||
XGraphMax := MinDouble;
|
||||
XGraphMin := MaxDouble;
|
||||
@ -998,19 +968,12 @@ begin
|
||||
if ParentChart <> nil then ParentChart.Invalidate;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
constructor TLine.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
FPen := TPen.Create;
|
||||
FPen.OnChange := StyleChanged;
|
||||
|
||||
|
||||
LineStyle := lsHorizontal;
|
||||
end;
|
||||
|
||||
@ -1045,7 +1008,6 @@ end;
|
||||
procedure TLine.SetPos(Value: Double);
|
||||
begin
|
||||
PosGraph:=Value;
|
||||
|
||||
//FIXME: not the best way of doing this
|
||||
{if Visible then begin
|
||||
NBPointsMax:=NBPointsMax+1;
|
||||
@ -1077,22 +1039,19 @@ var
|
||||
label Points;
|
||||
begin
|
||||
|
||||
with ParentChart as TChart do
|
||||
begin
|
||||
with ParentChart as TChart do begin
|
||||
XMin := XImageMin;
|
||||
XMax := XImageMax;
|
||||
YMin := YImageMin;
|
||||
YMax := YImageMax;
|
||||
end;
|
||||
|
||||
if XMin>XMax then
|
||||
begin
|
||||
if XMin>XMax then begin
|
||||
TempI:=XMin;
|
||||
XMin:=XMax;
|
||||
XMax:=TempI;
|
||||
end;
|
||||
if YMin>YMax then
|
||||
begin
|
||||
if YMin>YMax then begin
|
||||
TempI:=YMin;
|
||||
YMin:=YMax;
|
||||
YMax:=TempI;
|
||||
@ -1115,7 +1074,6 @@ case LineStyle of
|
||||
ACanvas.LineTo(PosImage, YMax);
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
@ -1138,7 +1096,8 @@ begin
|
||||
end;
|
||||
|
||||
destructor TBarSeries.Destroy;
|
||||
var i:integer;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FBarPen.Free;
|
||||
FBarBrush.Free;
|
||||
@ -1161,11 +1120,12 @@ begin
|
||||
FBarPen.Assign(Value);
|
||||
end;
|
||||
|
||||
Procedure TBarSeries.SetBarWidthPercent(Value:Integer);
|
||||
Begin
|
||||
procedure TBarSeries.SetBarWidthPercent(Value: Integer);
|
||||
begin
|
||||
if (Value < 1) or (Value > 100) then
|
||||
Raise BarException.Create('Wrong BarWidth Percent')
|
||||
else FBarWidthPercent := Value;
|
||||
raise BarException.Create('Wrong BarWidth Percent')
|
||||
else
|
||||
FBarWidthPercent := Value;
|
||||
end;
|
||||
|
||||
function TBarSeries.AddXY(X, Y: Double; XLabel: String; Color: TColor): Longint;
|
||||
@ -1174,7 +1134,7 @@ begin
|
||||
|
||||
inherited AddXY(X, Y, XLabel, Color);
|
||||
|
||||
//update the interval - the 0.6 is a hack to allow the bars to have some space appart
|
||||
//update the interval - the 0.6 is a hack to allow the bars to have some space apart
|
||||
if X > XGraphMax - 0.6 then XGraphMax := X + 0.6;
|
||||
if X < XGraphMin + 0.6 then XGraphMin := X - 0.6;
|
||||
//check if the bar is abouve 0 or not
|
||||
@ -1186,10 +1146,9 @@ begin
|
||||
if YGraphMax < 0 then YGraphMax := 0;
|
||||
end;
|
||||
|
||||
|
||||
if ParentChart <> nil then ParentChart.Invalidate;
|
||||
//this has to change
|
||||
result := 0;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
procedure TBarSeries.Draw(ACanvas: TCanvas);
|
||||
@ -1200,14 +1159,13 @@ var
|
||||
graphCoordBottom: ChartCoord;
|
||||
topX, topY, bottomY: Integer;
|
||||
barWidth, TotalbarWidth: Integer;
|
||||
bx1, by1, bx2, by2: Integer;
|
||||
|
||||
bx1, by1, bx2, by2: integer;
|
||||
|
||||
|
||||
function BarInViewPort( cTop, cBottom: ChartCoord ): boolean;
|
||||
function BarInViewPort(cTop, cBottom: ChartCoord): Boolean;
|
||||
begin //FIXME make cleaner?
|
||||
result := ( (cTop.x >= ParentChart.XGraphMin) and (cTop.x <= ParentChart.XGraphMax) )
|
||||
and ( ( (cTop.y > ParentChart.YGraphMax) and (cBottom.y < ParentChart.YGraphMin))
|
||||
Result :=
|
||||
((cTop.x >= ParentChart.XGraphMin) and (cTop.x <= ParentChart.XGraphMax)) and
|
||||
( ((cTop.y > ParentChart.YGraphMax) and (cBottom.y < ParentChart.YGraphMin))
|
||||
or ( (cTop.y < ParentChart.YGraphMax) and (cTop.y > ParentChart.YGraphMin))
|
||||
or ( (cBottom.y < ParentChart.YGraphMax) and (cBottom.y > ParentChart.YGraphMin))
|
||||
);
|
||||
@ -1231,11 +1189,11 @@ begin
|
||||
ACanvas.Brush.Assign(FBarBrush);
|
||||
|
||||
//calc the single bar width
|
||||
TotalbarWidth:=Round((FBarWidthPercent*0.01)*ParentChart.ChartWidth/FCoordList.Count);
|
||||
TotalbarWidth :=
|
||||
Round((FBarWidthPercent * 0.01) * ParentChart.ChartWidth / FCoordList.Count);
|
||||
//to use with multibar -- with is on by default
|
||||
barWidth := TotalbarWidth div ParentChart.NumBarSeries;
|
||||
|
||||
|
||||
for i := 0 to FCoordList.Count - 1 do begin
|
||||
//get the top and bottom points
|
||||
if ChartCoord(FCoordList.Items[i]^).y >= 0 then begin
|
||||
@ -1268,7 +1226,6 @@ begin
|
||||
bx2 := topX - (TotalbarWidth div 2) + SeriesNumber * barWidth + barWidth;
|
||||
by2 := bottomY;
|
||||
|
||||
|
||||
//FIXME only draw if bar inside image coord (get a better way of doing this)
|
||||
if (bx1 >= XMin) and (bx2 <= XMax) then
|
||||
if by1 = by2 then begin //draw a line when y=0 FIXME (clean)
|
||||
@ -1276,11 +1233,10 @@ begin
|
||||
ACanvas.MoveTo(bx1, by1);
|
||||
ACanvas.LineTo(bx2, by2);
|
||||
ACanvas.Pen.Assign(FBarPen);
|
||||
end else ACanvas.Rectangle( bx1, by1, bx2, by2);
|
||||
|
||||
end else
|
||||
ACanvas.Rectangle( bx1, by1, bx2, by2);
|
||||
end;
|
||||
end;
|
||||
|
||||
end; // for
|
||||
end;
|
||||
|
||||
constructor TPieSeries.Create(AOwner: TComponent);
|
||||
@ -1313,23 +1269,22 @@ begin
|
||||
FPiePen.Assign(Value);
|
||||
end;
|
||||
|
||||
|
||||
function TPieSeries.AddXY(X, Y: Double; XLabel: String; Color: TColor): Longint;
|
||||
begin
|
||||
if Color = clTAColor then Color := Colors[ColorIndex];
|
||||
Inc(ColorIndex); if ColorIndex > MaxColor then ColorIndex := 1;
|
||||
Inc(ColorIndex);
|
||||
if ColorIndex > MaxColor then ColorIndex := 1;
|
||||
|
||||
inherited AddXY(X, Y, XLabel, Color);
|
||||
|
||||
|
||||
if ParentChart <> nil then ParentChart.Invalidate;
|
||||
//this has to change
|
||||
result := 0;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TPieSeries.AddPie(Value: Double; Text: String; Color: TColor): Longint;
|
||||
begin
|
||||
result := AddXY( getXMinVal + 1, Value, Text, Color);
|
||||
Result := AddXY(getXMinVal + 1, Value, Text, Color);
|
||||
end;
|
||||
|
||||
procedure conv_angle(nOrigoX, nOrigoY, nLen: Integer; Angle: Double; var PX, PY: Integer);
|
||||
@ -1341,27 +1296,26 @@ end;
|
||||
procedure TPieSeries.Draw;
|
||||
var
|
||||
nOrigoX, nOrigoY: LongInt;
|
||||
nLen : integer;
|
||||
n100Sum: double;
|
||||
i, AX, AY, BX, BY: integer;
|
||||
curangle, prevangle, midleangle, prop: double;
|
||||
maxtextw: integer;
|
||||
nLen: Integer;
|
||||
n100Sum: Double;
|
||||
i, AX, AY, BX, BY: Integer;
|
||||
curangle, prevangle, midleangle, prop: Double;
|
||||
maxtextw: Integer;
|
||||
CircleRect: TRect;
|
||||
markrect: trect;
|
||||
markrect: TRect;
|
||||
W: Integer;
|
||||
graphCoord: PChartCoord;
|
||||
MarkTxtWidth: integer;
|
||||
const TAGSMargin = 20;
|
||||
MarkTxtWidth: Integer;
|
||||
SPACE_InMarks: integer;
|
||||
const
|
||||
TAGSMargin = 20;
|
||||
MarkYMargin = 2;
|
||||
MarkXMargin = 4;
|
||||
var
|
||||
SPACE_InMarks: integer;
|
||||
begin
|
||||
SPACE_InMarks := 40;
|
||||
//no elements to draw
|
||||
if FCoordList.Count = 0 then exit;
|
||||
|
||||
|
||||
//center the ParentChart on the canvas
|
||||
if ParentChart.XImageMax - ParentChart.XImageMin > ParentChart.YImageMin - ParentChart.YImageMax then begin
|
||||
W := ParentChart.YImageMin - ParentChart.YImageMax;
|
||||
@ -1372,10 +1326,8 @@ begin
|
||||
W := ParentChart.XImageMax - ParentChart.XImageMin;
|
||||
nOrigoX := Round((W - 1.01) / 2) + ParentChart.XImageMin;
|
||||
nOrigoY := (ParentChart.YImageMin - ParentChart.YImageMax) div 2 + ParentChart.YImageMax;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
prevangle := 0;
|
||||
maxtextw := 0;
|
||||
n100Sum := 0;
|
||||
@ -1389,7 +1341,7 @@ begin
|
||||
|
||||
//we can only draw if enought space for text is saved
|
||||
//so we remove maxtextw and MarkXMargin
|
||||
nLen := Round( (W-(maxtextw)*2) /2);
|
||||
nLen := Round((W - maxtextw * 2) / 2);
|
||||
CircleRect.Left := nOrigoX - nLen - TAGSMargin;
|
||||
CircleRect.Top := nOrigoY - nLen - TAGSMargin;
|
||||
CircleRect.Right := nOrigoX + nlen + TAGSMargin;
|
||||
@ -1407,53 +1359,58 @@ begin
|
||||
curangle := prop * (2 * pi) ;
|
||||
conv_angle(nOrigoX, nOrigoY, nLen, prevangle+curangle, BX, BY);
|
||||
|
||||
ParentChart.Canvas.Brush.color := graphCoord^.Color;
|
||||
ParentChart.canvas.pie(CircleRect.Left,CircleRect.Top, CircleRect.Right, CircleRect.Bottom, AX,AY,BX,BY);
|
||||
ParentChart.Canvas.Brush.Color := graphCoord^.Color;
|
||||
ParentChart.Canvas.Pie(
|
||||
CircleRect.Left, CircleRect.Top, CircleRect.Right, CircleRect.Bottom,
|
||||
AX, AY, BX, BY);
|
||||
|
||||
if nLen < SPACE_InMarks then
|
||||
SPACE_InMarks := nLen;
|
||||
|
||||
|
||||
//marks
|
||||
midleangle := prevangle + (curangle/2);
|
||||
midleangle := prevangle + curangle / 2;
|
||||
conv_angle(nOrigoX, nOrigoY, nLen + SPACE_InMarks, midleangle, BX, BY);
|
||||
conv_angle(nOrigoX, nOrigoY, nLen, midleangle, aX, aY);
|
||||
|
||||
ParentChart.canvas.Pen.Color := clWhite;
|
||||
ParentChart.canvas.moveto(ax, ay);
|
||||
ParentChart.canvas.lineto(bx, by);
|
||||
ParentChart.canvas.Pen.Color := clBlack;
|
||||
ParentChart.Canvas.Pen.Color := clWhite;
|
||||
ParentChart.Canvas.MoveTo(ax, ay);
|
||||
ParentChart.Canvas.LineTo(bx, by);
|
||||
ParentChart.Canvas.Pen.Color := clBlack;
|
||||
|
||||
//depends on label type
|
||||
case MarksStyle of
|
||||
smsLabel: MarkTxtWidth := ParentChart.canvas.TextWidth( graphCoord^.Text );
|
||||
smsLabelPercent: MarkTxtWidth := ParentChart.canvas.TextWidth( graphCoord^.Text+' '+format('%1.3g',[prop*100])+'%' );
|
||||
smsLabel: MarkTxtWidth := ParentChart.Canvas.TextWidth(graphCoord^.Text);
|
||||
smsLabelPercent:
|
||||
MarkTxtWidth := ParentChart.Canvas.TextWidth(
|
||||
graphCoord^.Text + ' ' + Format('%1.3g', [prop * 100]) + '%');
|
||||
end;
|
||||
|
||||
//line from mark to pie
|
||||
if Bx < nOrigoX then
|
||||
markrect.Left := BX - MarkTxtWidth - MarkXMargin
|
||||
else markrect.Left := BX -MarkXMargin;
|
||||
else
|
||||
markrect.Left := BX - MarkXMargin;
|
||||
markrect.Right := markrect.Left + MarkTxtWidth + MarkXMargin * 2;
|
||||
|
||||
markrect.Top := BY - MarkYMargin;
|
||||
markrect.Bottom := BY + ParentChart.canvas.textheight( graphCoord^.Text )+MarkYMargin;
|
||||
markrect.Bottom :=
|
||||
BY + ParentChart.Canvas.TextHeight(graphCoord^.Text) + MarkYMargin;
|
||||
|
||||
|
||||
ParentChart.canvas.Brush.Color := clYellow;
|
||||
ParentChart.Canvas.Rectangle(markrect.Left, markrect.Top, markrect.Right, markrect.Bottom);
|
||||
ParentChart.Canvas.Brush.Color := clYellow;
|
||||
ParentChart.Canvas.Rectangle(
|
||||
markrect.Left, markrect.Top, markrect.Right, markrect.Bottom);
|
||||
|
||||
if Bx < nOrigoX then BX := BX - MarkTxtWidth;
|
||||
ParentChart.canvas.Brush.Color := clYellow;
|
||||
ParentChart.Canvas.Brush.Color := clYellow;
|
||||
case MarksStyle of
|
||||
smsLabel: ParentChart.Canvas.TextOut(BX, BY, graphCoord^.Text);
|
||||
smsLabelPercent: ParentChart.Canvas.TextOut(BX, BY, graphCoord^.Text+' '+format('%1.3g',[prop*100])+'%');
|
||||
smsLabelPercent:
|
||||
ParentChart.Canvas.TextOut(
|
||||
BX, BY, graphCoord^.Text + ' ' + Format('%1.3g', [prop * 100]) + '%');
|
||||
end;
|
||||
|
||||
prevangle := prevangle + curangle;
|
||||
end;
|
||||
|
||||
|
||||
end; // for
|
||||
end;
|
||||
|
||||
|
||||
@ -1487,21 +1444,21 @@ begin
|
||||
if ParentChart <> nil then ParentChart.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TAreaSeries.SetAreaBrush(value: TBrush);
|
||||
procedure TAreaSeries.SetAreaBrush(Value: TBrush);
|
||||
begin
|
||||
FAreaBrush.Assign( value );
|
||||
FAreaBrush.Assign(Value);
|
||||
if ParentChart <> nil then ParentChart.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TAreaSeries.SetStairs(value: Boolean);
|
||||
procedure TAreaSeries.SetStairs(Value: Boolean);
|
||||
begin
|
||||
FStairs := value;
|
||||
if ParentChart <> nil then ParentChart.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TAreaSeries.SetInvertedStairs(value: Boolean);
|
||||
procedure TAreaSeries.SetInvertedStairs(Value: Boolean);
|
||||
begin
|
||||
FInvertedStairs := value;
|
||||
FInvertedStairs := Value;
|
||||
if ParentChart <> nil then ParentChart.Invalidate;
|
||||
end;
|
||||
|
||||
@ -1513,14 +1470,13 @@ end;
|
||||
|
||||
|
||||
procedure TAreaSeries.Draw;
|
||||
const Larg = 4;
|
||||
const
|
||||
Larg = 4;
|
||||
var
|
||||
i, j: Integer;
|
||||
|
||||
xi1, yi1, xi2, yi2: Integer;
|
||||
xg1, yg1, xg2, yg2: Double;
|
||||
Inside1, Inside2: Boolean;
|
||||
Chart1:TChart;
|
||||
YLeft, YRight, XBottom, XTop: Double;
|
||||
XLine, YLine: array[1..2] of Integer;
|
||||
BLeft, BRight, BBottom, BTop: Boolean;
|
||||
@ -1530,9 +1486,8 @@ var
|
||||
XMin, XMax, Ymin, Ymax, TempI: Integer;
|
||||
graphCoord: PChartCoord;
|
||||
iy_min: integer;
|
||||
|
||||
begin
|
||||
if count=0 then Exit;
|
||||
if Count = 0 then Exit;
|
||||
|
||||
with ParentChart do begin
|
||||
XMin:=XImageMin;
|
||||
@ -1558,8 +1513,7 @@ begin
|
||||
Canvas.Pen.Width:=1;
|
||||
end;
|
||||
|
||||
|
||||
for i:=0 to count-2 do begin
|
||||
for i := 0 to Count - 2 do begin
|
||||
graphCoord := FCoordList.Items[i];
|
||||
xg1 := graphCoord^.x;
|
||||
yg1 := graphCoord^.y;
|
||||
@ -1573,10 +1527,10 @@ begin
|
||||
ParentChart.Canvas.Pen.Color:= clBlack;
|
||||
ParentChart.Canvas.Brush.Color:= graphCoord^.Color;
|
||||
|
||||
|
||||
if (xg1>ParentChart.XGraphMin) and (xg2>ParentChart.XGraphMin) and (xg1<ParentChart.XGraphMax) and (xg2<ParentChart.XGraphMax) and
|
||||
(yg1>ParentChart.YGraphMin) and (yg2>ParentChart.YGraphMin) and (yg1<ParentChart.YGraphMax) and (yg2<ParentChart.YGraphMax) then
|
||||
begin
|
||||
if
|
||||
(xg1>ParentChart.XGraphMin) and (xg2>ParentChart.XGraphMin) and (xg1<ParentChart.XGraphMax) and (xg2<ParentChart.XGraphMax) and
|
||||
(yg1>ParentChart.YGraphMin) and (yg2>ParentChart.YGraphMin) and (yg1<ParentChart.YGraphMax) and (yg2<ParentChart.YGraphMax)
|
||||
then begin
|
||||
if FStairs then begin
|
||||
if FInvertedStairs then
|
||||
ParentChart.Canvas.Polygon([Point(xi1, iy_min), Point(xi1, yi2), Point(xi2, yi2), Point(xi2, iy_min)])
|
||||
@ -1588,8 +1542,10 @@ begin
|
||||
continue;
|
||||
end;
|
||||
|
||||
if ((xg1<ParentChart.XGraphMin) and (xg2<ParentChart.XGraphMin)) or ((xg1>ParentChart.XGraphMax) and (xg2>ParentChart.XGraphMax)) or
|
||||
((yg1<ParentChart.YGraphMin) and (yg2<ParentChart.YGraphMin)) or ((yg1>ParentChart.YGraphMax) and (yg2>ParentChart.YGraphMax)) then
|
||||
if
|
||||
((xg1<ParentChart.XGraphMin) and (xg2<ParentChart.XGraphMin)) or ((xg1>ParentChart.XGraphMax) and (xg2>ParentChart.XGraphMax)) or
|
||||
((yg1<ParentChart.YGraphMin) and (yg2<ParentChart.YGraphMin)) or ((yg1>ParentChart.YGraphMax) and (yg2>ParentChart.YGraphMax))
|
||||
then
|
||||
continue;
|
||||
|
||||
if yg1>yg2 then begin
|
||||
|
Loading…
Reference in New Issue
Block a user