做过也不发个demo 看下。<br>查了N多资料,自己解决了<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, TeeProcs, TeEngine, Chart, DbChart, ExtCtrls, DB,<br> ADODB,Series, Buttons;<br><br>type<br> TForm1 = class(TForm)<br> ADO: TADOConnection;<br> ADOQuery1: TADOQuery;<br> DataSource1: TDataSource;<br> Panel1: TPanel;<br> DBChart1: TDBChart;<br> Panel2: TPanel;<br> Button1: TButton;<br> Button2: TButton;<br> Series1: TLineSeries;<br> Button3: TButton;<br> Edit1: TEdit;<br> SpeedButton1: TSpeedButton;<br> OpenDialog1: TOpenDialog;<br> Label1: TLabel;<br> procedure Button1Click(Sender: TObject);<br><br> procedure FormCreate(Sender: TObject);<br><br> procedure Button3Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure SpeedButton1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> i:integer;<br> line1:TlineSeries;<br> myseries:TlineSeries;//线型<br> mypie :tpieseries;//饼型<br> series11:tbarseries;//柱型<br>implementation<br>uses data;<br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>VAR s,sqlstr:string;<br>begin<br>dbchart1.SeriesList.Clear;<br>myseries:= TLineSeries.Create(self);<br>DBChart1.AddSeries(myseries);<br>sqlstr:='select dyzrzfs,count(dyzrzfs) yi from book_table group by dyzrzfs ';<br>dm.SqlOpen(adoquery1,sqlstr);<br>with DBChart1 do<br> begin<br> with myseries do<br> begin<br> DataSource:=ADOQuery1;<br> XLabelsSource:='dyzrzfs';<br><br> YValuES.ValueSource:='YI';<br> end;<br> end;<br> myseries.Title:='dyzrzfs';<br> myseries.Active:=true;<br> dbchart1.BottomAxis.Title.caption:='第一责任者';<br> dbchart1.leftAxis.Title.caption:='数量';<br> dbchart1.leftAxis.Title.Angle:=0;<br> dbchart1.AxisVisible:=true;<br> if edit1.text<>'' then<br> dbchart1.BackImage.LoadFromFile(edit1.text);<br> dbchart1.Title.Text.Text:='asdf';<br> dbchart1.AutoSize:=true;<br> dbchart1.LeftAxis.Axis.Color:=clred;<br>end;<br><br><br><br><br><br>procedure TForm1.FormCreate(Sender: TObject);<br>var sqlstr:string;<br>begin<br> ado.Connected:=false;<br> ado.ConnectionString :='FILE NAME='+pchar(ExtractFilePath(ParamStr(0)))+'manage.UDL';<br> try<br> ado.Connected:=true;<br> except<br> Application.MessageBox('数据库关联错误!','提示',MB_OK+MB_ICONERROR);<br> application.Terminate;<br> end;<br>end;<br><br><br><br>procedure TForm1.Button3Click(Sender: TObject);<br>var sqlstr:string;<br>begin<br> dbchart1.SeriesList.Clear;<br>series11:= tbarseries.Create(self);<br>DBChart1.AddSeries(series11);<br>sqlstr:='select dyzrzfs,count(dyzrzfs) yi from book_table group by dyzrzfs ';<br>dm.SqlOpen(adoquery1,sqlstr);<br>with DBChart1 do<br> begin<br> with series11 do<br> begin<br> DataSource:=ADOQuery1;<br> XLabelsSource:='dyzrzfs';<br> YValuES.ValueSource:='YI';<br> end;<br> end;<br> series11.Title:='dyzrzfs';<br> series11.Active:=true;<br> dbchart1.BottomAxis.Title.caption:='第一责任者';<br> dbchart1.leftAxis.Title.caption:='数量';<br> dbchart1.leftAxis.Title.Angle:=0;<br> dbchart1.AxisVisible:=true;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var sqlstr:string;<br>begin<br> dbchart1.SeriesList.Clear;<br> mypie:= tpieseries.Create(self);<br> DBChart1.AddSeries(mypie);<br> sqlstr:='select dyzrzfs,count(dyzrzfs) yi from book_table group by dyzrzfs ';<br> dm.SqlOpen(adoquery1,sqlstr);<br> with DBChart1 do<br> begin<br> with mypie do<br> begin<br> DataSource:=ADOQuery1;<br> XLabelsSource:='dyzrzfs';<br> YValuES.ValueSource:='YI';<br> end;<br> end;<br> mypie.Title:='dyzrzfs';<br> mypie.Active:=true;<br> dbchart1.BottomAxis.Title.caption:='第一责任者';<br> dbchart1.leftAxis.Title.caption:='数量';<br> dbchart1.leftAxis.Title.Angle:=0;<br> dbchart1.AxisVisible:=true;<br><br>end;