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又要显示对应的时期怎么搞