我的解决方案,动态赋值 (可根据要求创建多个TBarSeries):
Procedure TForm1.SetChartView;
Type TRecSalesUP = Record
ShipQty: Real;
MonthX: String;
end;
var ArrSalesUP: Array of TRecSalesUP;
ArrBar: TBarSeries;
I: Integer;
begin
with BasDM.SP_Q_CostingShipdo
begin
I := 0;
SetLength(ArrSalesUP,RecordCount);
First;
while not Eofdo
begin
ArrSalesUP.MonthX := FieldByName('MonthX').AsString;
ArrSalesUP.ShipQty := FieldByName('TemACount').AsFloat;
Inc(I);
Next;
end;
Close;
end;
ArrBar:= TBarSeries.Create(Self);
ArrBar.ParentChart := Chart1;
ArrBar.ShowInLegend := False;
ArrBar.GetVertAxis.Minimum := 0;
ArrBar.Marks.Style := smsValue;
ArrBar.Marks.ArrowLength := 10+I*40;
//赋各柱形值
For I:=Low(ArrSalesUP) to High(ArrSalesUP)do
ArrBar.AddBar(Round(ArrSalesUP.ShipQty) Div 1000,ArrSalesUP.MonthX,$00DC987E);
Chart1.Refresh;
end;