下面是简单的例子:
var
i , j , kum : Integer ;
s , t : TBarSeries ;
begin
with Chart1 do
begin
// Title of the Chart
SeriesList . Clear ;
Title . Text . Clear ;
Title . Text . Add ( 'My Title for Char' );
Legend . Visible := True ;
Legend . LegendStyle := lsAuto ;
Legend . TextStyle := ltsLeftValue ;
// Create first Series
s := TBarSeries . Create ( nil );
// Clear it
s . Clear ;
s . BarStyle := bsRectGradient ;
s . ColorEachPoint := True ;
// set the title
s . Title := 'Bar 1' ;
// determine the chart, this series belongs to
s . ParentChart := Chart1 ;
// the x-axis shall use date
s . XValues . DateTime := False ;
s . AutoBarSize := False ;
s . BarWidthPercent := 70 ;
s . OffsetPercent := 0 ;
s . Marks . Style := smsPercent ;
// create the second Series
t := TBarSeries . Create ( nil );
t . Clear ;
t . Title := 'Bar 2' ;
t . ParentChart := Chart1 ;
t . XValues . DateTime := False ;
// this series uses the right axis
t . VertAxis := aLeftAxis ;
// now add the random values
Randomize ;
for i := 0 to 5 do
begin
j := Random ( 100 ) + 1 ;
s . AddXY ( i , j );
kum := j ;
t . AddXY ( i , kum + Random ( 20 ));
end ;
end ;
end ;