我正在使用查询要在图表中显示的数据:
procedure TfrmUsage.ShowIndUsage(Sender: TObject);
var
tmpQuery: TQuery;
mTotal: integer;
startMon: string;
g1: TSeriesGroup;
begin
Series7.Active:= False;
Series0.Clear;
Series1.Clear;
Series2.Clear;
Series0.Active:= True; // member 0
Series1.Active:= True; // member 1
Series2.Active:= True; // membership total
tmpQuery:= TQuery.Create(nil);
chrtUsage.Title.Text.Clear;
with tmpQuery do begin
DatabaseName:= Sessions.CurrentSession.Databases[0].DatabaseName;
SessionName:= Sessions.CurrentSession.SessionName;
SQL.Text:= 'select trim(fname)||" "||trim(lname) from asamembr ' + ' where cust_code = :custCode ' + ' and mbr_code = :mbrCode ';
Params[0].AsString:= Self.fCustCode;
Params[1].AsString:= '0'; // self.fmbrCode;
Open;
chrtUsage.Title.Text.add('Usage for Member ' + Fields[0].AsString + ' (yellow)');
Close;
Params[1].AsString:= '1'; // self.fmbrCode;
Open;
if not EOF then chrtUsage.Title.Text.add('Usage for Member ' + Fields[0].AsString + ' (red)')
else Series1.Active:= False;
chrtUsage.Title.Text.add('Usage for Membership (green)');
Close;
SQL.Text:= 'select extend(usage_date, year to month), mbr_code, count(*) from as ambrhis ' +
' where asambrhis.cust_code = :custCode ' + ' and usage_date > today - 1 units year ' + ' group by 1,2 order by 1 ';
Params[0].AsString:= Self.fCustCode;
try
Open;
mTotal:= 0;
startMon:= FormatDateTime('mmm/yyyy', Fields[0].AsDateTime);
while not EOF do begin
// chrtUsage.SeriesGroups.Items[0].Show;
chrtUsage.Axes.Bottom.Labels:= True;
chrtUsage.Axes.Bottom.LabelsSize:= 10;
chrtUsage.BottomAxis.Visible:= True;
chrtUsage.BottomAxis.Axis.Show;
if startMon <> FormatDateTime('mmm/yyyy', Fields[0].AsDateTime) then begin
Series2.add(mTotal, startMon);
// Series2.Add
if Series1.Active then // make sure we have all series bars
if Series0.Count < Series1.Count then Series0.add(0, startMon)
else if Series1.Count < Series0.Count then Series1.add(0, startMon);
startMon:= FormatDateTime('mmm/yyyy', Fields[0].AsDateTime);
mTotal:= 0;
end;
mTotal:= Fields[2].AsInteger + mTotal;
if Fields[1].AsString = '0' then Series0.add(Fields[2].AsInteger, startMon)
else if Fields[1].AsString = '1' then Series1.add(Fields[2].AsInteger, startMon);
Next;
end;
Series2.add(mTotal, startMon);
Close;
finally
tmpQuery.Free;
end;
end;
end;
在此代码中,变量 startMon 需要显示为底部轴的标签。请指导如何实现。我已将标记设置为标签和值,然后在底部轴中将标题设置为标记,或者我也尝试使用值,两者都不起作用