dbchart中如何动态更改它的xlabelsSource的值(50分)

  • 主题发起人 主题发起人 dontal
  • 开始时间 开始时间
D

dontal

Unregistered / Unconfirmed
GUEST, unregistred user!
统计学生人数,分别按年级(stnianji)和专业(zhuanyename)来统计,已经将ADOQuery设
成动态可更改,并动态更改XLabelsSource的值,若只按年级或只按专业来统计均可正常运行,
但先按年级统计,再按专业统计就会提示出错“字段stnianji没有找到”,反过来也是一样,
请问各位大侠怎么解决这个问题,急死我了!!!
 
这是你地查询语句地问题吧
series.datasource:=adoquery1;
series.xvalue.valuesource:='nianji';
series.yvalue.valuesource:='renshu';

动态改变
 
代码如下:
case RadioGroup5.ItemIndex of
0://按年级
sql := 'select nums=count(stinfo.stname),stinfo.stnianji from stinfo inner join zhuanye on stinfo.stzhuanye=zhuanye.zhuanyedm group by stinfo.stnianji';
1://按专业
sql := 'select nums=count(stinfo.stname),zhuanye.zhuanyename from stinfo inner join zhuanye on stinfo.stzhuanye=zhuanye.zhuanyedm group by zhuanye.zhuanyename';
end;

with DataModule1.cdsTongJi do
begin
Close;
Commandtext := sql ;
Open;
end;

mySeries := nil;//前面声明myseries:TChartseries;

case RadioGroup5.ItemIndex of
0:
begin
DBChart1.SeriesList.Clear;
if Assigned(mySeries) then mySeries.Destroy;
mySeries := TBarSeries.Create(self);
mySeries.ParentChart := DBChart1;
mySeries.DataSource := DataModule1.cdsTongji;
mySeries.YValues.ValueSource := 'nums';
mySeries.XLabelsSource := 'stnianji';
mySeries.SeriesColor := clBlue;
end;

1:
begin
DBChart1.SeriesList.Clear;
if Assigned(mySeries) then mySeries := nil;
mySeries := TPieSeries.Create(self);
mySeries.ParentChart := DBChart1;
mySeries.DataSource := DataModule1.cdsTongji;
mySeries.YValues.ValueSource:= 'nums';
mySeries.XLabelsSource := 'zhuanyename';//这里用Xvalues.ValueSource好象不行
end;
end;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部