tdbchart 到底怎么用?为什么我在series中的data source中指定了adoquery1.并且连接好了。sql查询为:select moon,sum(money) money
          from tb
          group by moon
tb为数据库。可是 x,y都是money
各位大虾帮帮我!

解决方案 »

  1.   

    可以动态设置xy坐标的字段。
    设计时也可,你在source里再指定一下,应该没问题的!
      

  2.   

    procedure  tchartform.getbar(x,y:string);
    var series1:tbarseries;
    begin
      series1:=tbarseries.Create(self);
      series1.ParentChart:=dbchart1;
      series1.DataSource:=adoquery1;
      series1.XLabelsSource:=x;
      series1.yValues.ValueSource:=y;
      series1.Title:=x;
     // series1.XLabelsSource:
      series1.Active:=true;
      dbchart1.BottomAxis.Title.caption:=x;
      dbchart1.leftAxis.Title.caption:=y;
      dbchart1.leftAxis.Title.Angle:=0;
    end;
      

  3.   

    提供例子慢慢看...
    procedure TForm_SJFX_XSFX.ShowChart(itype: integer; Dset: TQuery; xlabel,
      yvalues: string);
    var
      vPie: TPieSeries;
      vBar: TBarSeries;
      vLine: TLineSeries;
      i: integer;
    begin
      isMannul := false;
      while DBChart.SeriesCount > 0 do DBChart.SeriesList[0].Destroy;
      DBChart.Title.Text.Clear;
      DBChart.Title.Text.Add(ChartTitle);
      DBChart.LeftAxis.Title.Caption := yvalues;
      DBChart.BottomAxis.Title.Caption := xlabel;
      //
      if itype = 0 then
      begin
        vBar := TBarSeries.Create(nil);
        vBar.ParentChart := DBChart;
        vBar.DataSource := Dset;
        vBar.YValues.ValueSource := yvalues;
        vBar.XLabelsSource := xlabel;
        vBar.Marks.Style := smsValue;
        DBChart.AddSeries(vBar);
      end
      else if itype = 2 then
      begin
        vPie := TPieSeries.Create(nil);
        vPie.ParentChart := DBChart;
        vPie.DataSource := Dset;
        vPie.YValues.ValueSource := yvalues;
        vPie.XLabelsSource := xlabel;
        vPie.Marks.Style := smsLabelPercent;
        DBChart.AddSeries(vPie);
      end
      else
      begin
        vLine := TLineSeries.Create(nil);
        vLine.ParentChart := DBChart;
        vLine.DataSource := Dset;
        vLine.YValues.ValueSource := yvalues;
        vLine.XLabelsSource := xlabel;
        vLine.Marks.Style := smsLabelPercent;
        DBChart.AddSeries(vLine);
      end;
    end;
      

  4.   

    我数据库里面的数据都是字符,倒是可以转换成DATETIME格式和浮点格式的,我该怎么样连接到图表的X,Y轴上呢?