Moves the barchart import from dataset from dbctrls to barchart

git-svn-id: trunk@30388 -
This commit is contained in:
sekelsenmat 2011-04-19 18:34:50 +00:00
parent 7381149462
commit 12e3b2bf20
2 changed files with 37 additions and 37 deletions

View File

@ -33,7 +33,7 @@ interface
uses
Types, SysUtils, Classes, LCLProc, LCLIntf, LCLType, Controls, ExtCtrls, Graphics,
Dialogs;
Dialogs, db;
type
@ -154,6 +154,9 @@ type
procedure Register;
procedure FillBarChart(BC: TBarChart; DS: TDataset;
const LabelField, ValueField: String; AColor: TColor);
implementation
procedure Register;
@ -163,6 +166,38 @@ begin
{$WARNINGS on}
end;
procedure FillBarChart(BC: TBarChart; DS: TDataset;
const LabelField, ValueField: String; AColor: TColor);
Var
LF : TList;
VF : TField;
I : Integer;
L : String;
begin
VF:=DS.FieldByName(ValueField);
LF:=TList.Create;
Try
DS.GetFieldList(LF,LabelField);
With DS do
begin
While Not EOF do
begin
L:='';
For I:=0 to LF.Count-1 do
begin
If L<>'' then
L:=L+' ';
L:=L+TField(LF[i]).AsString;
end;
BC.AddBar(L, VF.AsInteger, AColor);
Next;
end;
end;
Finally
LF.Free;
end;
end;
constructor TCustomBarChart.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

View File

@ -39,7 +39,7 @@ uses
Types, Classes, SysUtils, DB,
LCLStrConsts, LCLProc, LMessages, LCLType, LResources, GraphType,
Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons, MaskEdit, ExtCtrls,
Calendar, BarChart, Variants;
Calendar, Variants;
Type
{ TFieldDataLink }
@ -1272,9 +1272,6 @@ type
// ToDo: Move this to db.pp
function ExtractFieldName(const Fields: string; var StartPos: Integer): string;
procedure FillBarChart(BC: TBarChart; DS: TDataset;
const LabelField, ValueField: String; AColor: TColor);
procedure ChangeDataSource(AControl: TControl; Link: TDataLink;
NewDataSource: TDataSource);
@ -1312,38 +1309,6 @@ begin
StartPos:=i;
end;
procedure FillBarChart(BC: TBarChart; DS: TDataset;
const LabelField, ValueField: String; AColor: TColor);
Var
LF : TList;
VF : TField;
I : Integer;
L : String;
begin
VF:=DS.FieldByName(ValueField);
LF:=TList.Create;
Try
DS.GetFieldList(LF,LabelField);
With DS do
begin
While Not EOF do
begin
L:='';
For I:=0 to LF.Count-1 do
begin
If L<>'' then
L:=L+' ';
L:=L+TField(LF[i]).AsString;
end;
BC.AddBar(L, VF.AsInteger, AColor);
Next;
end;
end;
Finally
LF.Free;
end;
end;
procedure ChangeDataSource(AControl: TControl; Link: TDataLink;
NewDataSource: TDataSource);
begin