我在数据模块中定义了个Query控件,在Form中我使用了个DBChart控件,我没有在chart的属性设置界面里为Seriesline绑定查询结果,我在程序中是这样使用的,但程序运行时曲线没有显示出来,请求高手指教?
附程序:
 ......
    datamodule.DataModule1.QUERY3.Close;
    datamodule.DataModule1.QUERY3.SQL.Clear;
    datamodule.DataModule1.QUERY3.SQL.Text:='SELECT d001,((t092):fprop1),t093,t094,((t096)*:fprop2) FROM pc10m WHERE D001>:PARAM1 and D001<=:param2 order by d001 desc';
    datamodule.DataModule1.QUERY3.ParamBYname('param1').AsDateTime:=dd;
    datamodule.DataModule1.QUERY3.ParamBYname('param2').AsDateTime:=t;
    datamodule.DataModule1.QUERY3.ParamBYname('fprop1').AsFloat:=fprop1;
    datamodule.DataModule1.QUERY3.ParamBYname('fprop2').AsFloat:=fprop2;
    datamodule.DataModule1.QUERY3.Open;    LineSeries5:=TLineSeries.Create(self);
    With LineSeries5 do
    begin
       ParentChart:=DBChart3;
       DataSource:=datamodule.DataModule1.QUERY3;
       XLabelsSource:='d001';
       YValues.ValueSource:= 'exp_2';
       CheckDatasource;
    end;
............

解决方案 »

  1.   

    1 ,确保你的Query没有问题,别的方法看看有其中没有数据
    2,DBChart有时候很奇怪的,建议还是拉一个到窗体上看看,不要生成,有时要把它删掉再放一个才可以出现数据的图形的,
      DBChart1.Series[0].DataSource:=Query1 ;
      DBChart1.Series[0].XLabelsSource:='xx';
      DBChart1.Series[0].XValues.ValueSource:='yy';
      DBChart1.Series[0].YValues.ValueSource:='cc';
      DBChart1.Series[0].CheckDataSource;
      

  2.   

    我做的图形生成窗体,可以根据用户的统计表及用户选择图形模式形成统计图
    试试如下方法:
    LineSeries5应该在设计时创建
    With LineSeries5 do
        begin
           Clear;//清空
           ParentChart:=DBChart3;
    //先制空
           DataSource:='';
           XLabelsSource:='';
           YValues.ValueSource:= '';
    //在赋值
           DataSource:=datamodule.DataModule1.QUERY3;
           XLabelsSource:='d001';
           YValues.ValueSource:= 'exp_2';
           CheckDatasource;
        end;
      

  3.   

    //點Bitbtn1則畫出圖表!
    procedure TForm1.BitBtn1Click(Sender: TObject);
    var i:integer;
    begin
      chart1.Visible:=true;
      table1.open;
      series1.Clear;
      for i:=0 to 9 do
        begin
          if not table1.Eof then
            if i mod 2 =0 then
             series1.add(Table1Salary.asinteger,table1lastname.asstring,clyellow)
            else series1.add(table1salary.asinteger,table1lastname.asstring,clred)
          else begin
                table1.first;
                abort;
               end;
          table1.next;
        end;