with dmAllWeb.ADOQuery3 do
  begin
    SQL.Clear;
    SQL.Add('select * from table where 代码 = ' + '''600000''');
    Open;
  end;  DBChart1.Series[0].DataSource := dmAllWeb.ADOQuery3;以上代码得到一个表:     日期      代码   散户  中户  大户  法人   机构
 20080322  600000  2.9  1.3   1   43.9  50.9如何将以上这个表用通过柱状图表现出来,每个柱子分别表示:散户 中户 大户 法人 机构, 
散户 + 中户+ 大户 + 法人 + 机构 = 100, 纵坐标的刻度最大值就是100.
我用以下代码不用实现。
  DBChart1.Series[0].YValues.ValueSource := '代码';
  DBChart1.Series[0].XValues.ValueSource := '散户';
  DBChart1.Series[0].XValues.ValueSource := '中户';
  DBChart1.Series[0].XValues.ValueSource := '大户';
  DBChart1.Series[0].XValues.ValueSource := '法人';
  DBChart1.Series[0].XValues.ValueSource := '机构';

解决方案 »

  1.   

    楼主 一个Series里面的XValues和YValues一般只对应一个字段。你上面对应的多个字段肯定是不对的。
    个人觉得你的表应该是这样的:
    类型 数值
    散户  2.9
    中户  1.3
    大户  1
    法人  43.9
    机构  50.9  SQL.Clear;
      SQL.Add('select 类型,数值 from table where 代码 = ' + '''600000'''');
      SQL.Add(' GROUP BY 类型') ;
      open;
      dbchart_tjjg.Series[0].Active:=false;
      dbchart_tjjg.Series[0].DataSource:=ADOQuery3;
      dbchart_tjjg.Series[0].XLabelsSource:='类型';
      dbchart_tjjg.Series[0].YValues.ValueSource:='数值';
      dbchart_tjjg.Series[0].Active:=true;
      

  2.   


    select * from 

      select 代码 as stockCodeName , 日期 as date, Subject = '散户' , Result = 散户 from #a
      union all 
      select 代码 as stockCodeName , 日期 as date, Subject = '中户' , Result = 中户 from #a
      union all 
      select 代码 as stockCodeName , 日期 as date, Subject = '大户' , Result = 大户 from #a
      union all 
      select 代码 as stockCodeName , 日期 as date, Subject = '法人' , Result = 法人 from #a
      union all
      select 代码 as stockCodeName , 日期 as date, Subject = '机构' , Result = 机构 from #a 
    ) t 
    order by stockCodeName, date, case Subject when '散户' then 1 when '中户' then 2 when '大户' then 3 when '法人' then 4 when '机构' then 5 end 
      

  3.   


    select * from 

      select 代码 as stockCodeName , 日期 as date, Subject = '散户户数' , Result = 散户户数 from #a
      union all 
      select 代码 as stockCodeName , 日期 as date, Subject = '法人户数' , Result = 法人户数 from #a
      union all
      select 代码 as stockCodeName , 日期 as date, Subject = '机构户数' , Result = 机构户数 from #a 
    ) t 
    order by stockCodeName, date, case Subject when '散户户数' then 1 when '法人户数' then 2 when '机构户数' then 3 end