chart的问题xlabel(100)

  • 主题发起人 主题发起人 wlyft
  • 开始时间 开始时间
W

wlyft

Unregistered / Unconfirmed
GUEST, unregistred user!
with form1.localADOQuery do begin close; sql.clear; sql.add('select max(wmoneny) as maxmoney from ' +'(SELECT cstr(format(wdate,''yyyy-mm-dd'')) AS wdate, SUM(wmoneny) AS wmoneny FROM wmaintable ' +'where (wdate between #'+trim(maskedit14.text)+'# and #'+trim(maskedit15.text)+'#) ' +'GROUP BY cstr(format(wdate,''yyyy-mm-dd'')) ) DERIVEDTBL '); open; First; chart1.leftaxis.maximum:=FieldByName('maxmoney').AsInteger+100 ; //Y轴定最大值 close; sql.clear; sql.add('SELECT cstr(format(wdate,''yyyy-mm-dd'')) AS wdate FROM wmaintable ' +'where (wdate between #'+trim(maskedit14.text)+'# and #'+trim(maskedit15.text)+'#) ' +'GROUP BY cstr(format(wdate,''yyyy-mm-dd'')) '); open; First; chart1.Bottomaxis.Maximum :=recordcount+1; //X轴定最大值 xmax:= recordcount ; i:=0; while not Eof do begin chart1.Series[0].XLabel:=FieldByName('wdate').Asstring; //X轴标赋值 chart1.Series[1].XLabel:=FieldByName('wdate').Asstring; //X轴标赋值 i:=i+1; next; end; //while close; sql.clear; sql.add('SELECT cstr(format(wdate,''yyyy-mm-dd'')) AS wdate , SUM(wmoneny) AS wmoneny FROM wmaintable ' +'where ((wdate between #'+trim(maskedit14.text)+'# and #'+trim(maskedit15.text)+'#) and (wincomestyle=''收'')) ' +'GROUP BY cstr(format(wdate,''yyyy-mm-dd'')) '); open; First; i:=0; while not Eof do begin for I := 0 to xmax- 1 do begin if chart1.Series[0].XLabel=FieldByName('wdate').Asstring then begin chart1.series[0].addxy(i,FieldByName('wmoneny').Asinteger); break; end; end; next; end; close; sql.clear; sql.add('SELECT cstr(format(wdate,''yyyy-mm-dd'')) AS wdate , SUM(wmoneny) AS wmoneny FROM wmaintable ' +'where ((wdate between #'+trim(maskedit14.text)+'# and #'+trim(maskedit15.text)+'#) and (wincomestyle=''支'')) ' +'GROUP BY cstr(format(wdate,''yyyy-mm-dd'')) '); open; First; i:=0; while not Eof do begin for I := 0 to xmax- 1 do begin if chart1.Series[1].XLabel=FieldByName('wdate').Asstring then begin chart1.series[1].addxy(i,FieldByName('wmoneny').Asinteger); break; end; end; next; end;Xlable怎么显示不出来呢,就后面加 close; sql.clear; sql.add('SELECT cstr(format(wdate,''yyyy-mm-dd'')) AS wdate FROM wmaintable ' +'where (wdate between #'+trim(maskedit14.text)+'# and #'+trim(maskedit15.text)+'#) ' +'GROUP BY cstr(format(wdate,''yyyy-mm-dd'')) '); open; First; i:=0; while not Eof do begin chart1.Series[0].XLabel:=FieldByName('wdate').Asstring; //X轴标赋值 chart1.Series[1].XLabel:=FieldByName('wdate').Asstring; //X轴标赋值 i:=i+1; next; end; 也显示不对呢,日期会中间拉很长间隔不显示呢Series[0]对应的收入数据比方说2010-01-01 502010-01-03 602010-01-07 202010-02-08 100Series[1]对应的支出数据比方说2010-01-07 502010-01-08 602010-01-10 202010-02-04 1002010-02-08 100收入支出的记录条数不相同,日期也不一定一样要在同一个chart的两条线显示出来,下面的xlabel又要显示对应的时期怎么搞
 
我觉得你还是不要两条线都有一个时间的好,因为你要是想一个没有时间的点加上那只能y轴填0,这样的曲线就不对了,delphi下有tchart的例子,你看看例子就会了
 
我就要样子的,0就0
 
那你就直接可以在数据库表内把收入和支出的表联合查询,然后空值为0就可以了啊,用这个联合查询的结果值往chart里添加啊
 
问题是收入和支出是两条线,不是一条线
 
恩,可以两条线啊,两个series就可以了啊,delphi下有例子,看看就可以了
 
你可不可以加我QQ3523956
 
公司不让上QQ,不好意思,你看看例子吧
 
弄不懂的上来问就好了,好多人会给你解答的
 
后退
顶部