路过的兄弟,指一点下小弟dbchart的使用(100分)

  • 主题发起人 主题发起人 txzhf
  • 开始时间 开始时间
T

txzhf

Unregistered / Unconfirmed
GUEST, unregistred user!
var &nbsp; myseries:TBarSeries;<br>begin<br>&nbsp;with &nbsp;self.ADOQuery1 &nbsp;do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; close ;<br>&nbsp; &nbsp; &nbsp; sql.Clear ;<br>&nbsp; &nbsp; &nbsp; sql.Add('select 性别, count(*) as 人口数量 &nbsp;from &nbsp;户主_家庭成员 &nbsp;group &nbsp;by 性别');<br>&nbsp; &nbsp; &nbsp; open;<br>&nbsp; &nbsp; &nbsp;dbchart1.SeriesList.Clear;<br>&nbsp; &nbsp; &nbsp;myseries:= &nbsp; TBarSeries.Create(self);<br>&nbsp; &nbsp; &nbsp;myseries.ParentChart:=dbchart1;<br>&nbsp; &nbsp; &nbsp;myseries.DataSource:=self.ADOQuery1;<br>&nbsp; &nbsp; &nbsp;myseries.XValues.ValueSource:='人口数量';<br>&nbsp; &nbsp; // 如果 &nbsp; &nbsp;myseries.YValues.ValueSource:='性别'; 则出现错误,指高手指点一下<br>&nbsp; &nbsp; &nbsp;myseries.YValues.ValueSource:='人口数量';<br>&nbsp; &nbsp; &nbsp;//<br>&nbsp; &nbsp;end;<br>小弟想在x轴显示性别:如男、女<br>&nbsp; &nbsp; &nbsp; &nbsp; y轴显示 男、女性别相对应的数量
 
我写的,ok<br>myseries.XLabelsSource:='性别' &nbsp;就可以了。<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var &nbsp; myseries:TBarSeries;<br>begin<br>&nbsp;with &nbsp;self.ADOQuery1 &nbsp;do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; close ;<br>&nbsp; &nbsp; &nbsp; sql.Clear ;<br>&nbsp; &nbsp; &nbsp; sql.Add('select xb,count(*)as sl from series group by xb');<br>&nbsp; &nbsp; &nbsp; open;<br>&nbsp; &nbsp; &nbsp;dbchart1.SeriesList.Clear;<br>&nbsp; &nbsp; &nbsp;myseries:= &nbsp; TBarSeries.Create(self);<br>&nbsp; &nbsp; &nbsp;myseries.ParentChart:=dbchart1;<br>&nbsp; &nbsp; &nbsp;myseries.DataSource:=self.ADOQuery1;<br><br>&nbsp; &nbsp; &nbsp;myseries.XLabelsSource:= 'xb'; &nbsp;//关键是这一句<br><br>&nbsp; &nbsp; &nbsp;myseries.YValues.ValueSource:='sl';<br>&nbsp; &nbsp;end;<br>end;
 
后退
顶部