我的表中有 [商品号][定货日期][数量]
我用了select [定货日期],[商品号],sum(进货数量) from [进货管理] group by [定货日期] ,[商品号]
我想在DBCHART中统计
Y:=数量的总和
X:=日期
每个商品用一条曲线表示
要怎么实现??
怎么能在不知道具体的商品号的情况下怎么能动态创建DBchart的Series?
怎么在一张表中分离出[商品号]相等的记录创建Series?
我用了select [定货日期],[商品号],sum(进货数量) from [进货管理] group by [定货日期] ,[商品号]
我想在DBCHART中统计
Y:=数量的总和
X:=日期
每个商品用一条曲线表示
要怎么实现??
怎么能在不知道具体的商品号的情况下怎么能动态创建DBchart的Series?
怎么在一张表中分离出[商品号]相等的记录创建Series?
type
linearray=array of TlineSeries;
datasetarray=array of TClientDataset;
var
line: linearray;
dataset: datasetarray;
i:integer;
begin
self.ClientDataSet1.Close;
self.ClientDataSet1.CommandText:='select [商品号]from[进货管理]group by [商品号]';
self.ClientDataSet1.Open;
self.ClientDataSet1.First;
showmessage('a');
for i:=0 to self.ClientDataSet1.RecordCount-1 do
begin
line[i]:=TlineSeries.Create(nil);//这里出错
dataset[i]:= TClientDataset.Create(nil);
dataset[i].RemoteServer:=DataModule2.DCOMConnection1;
dataset[i].ProviderName:='dataset[i]';
dataset[i].CommandText:='select month[定货日期]as [日期],sum(进货数量)as[合计数量] from [进货管理]where [商品号]='+#39+self.ClientDataSet1.FieldByName('商品号').AsString+#39+' group by month[定货日期]';
dataset[i].Open;
line[i].Clear;
line[i].ParentChart := DBChart1;
line[i].DataSource:=dataset[i];
line[i].YValues.ValueSource := '合计数量';
line[i].XValues.ValueSource := '日期';
DBChart1.AddSeries(line[i]);
DBChart1.Series[i].Active := True;
self.ClientDataSet1.Next;
end;不知道为什么那行会出错??
setlength(linearray,100);
setlength(datasetarray,100);
对啊 忘了
不过现在还出错啊。。
setlength(linearray,100);//出错
提示信息“'(' expected but ',' found”
怎么会这样啊 。。
中间用分号试下
看了之后应该就明白了
就是。
不行啊
提示信息“'(' expected but ',' found”
怎么会这样啊 。。
2、如果想要显示的series少的话可以全部先添加上去,然后设置active属性为false,这样series就不可见了,等到要显示的时候把active属性改成True就行了。
建议楼主自己再检查一下,我这样试了一下,对的啊
var
Form1: TForm1;implementation{$R *.dfm}
var
Line:array of TlineSeries;
I:Integer;
begin
SetLength(Line,10);
for I:=0 to 9 do
Line[I]:=TlineSeries.Create(nil);
end.--------------------
顺便借楼主的宝地问个问题,在动态创建了这些Series之后,如果不手工free的话行不行?
如果不手工Free的话在主程序结束后Delphi会自动释放这些Series对象吗?谢谢