这是一个Tchart的例子:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, ExtDlgs;
type
TForm1 = class(TForm)
Chart1: TChart;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Series; //±ØÐëÒª¼ÓÉÏÈ¥
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
Series1: TBarSeries;
begin
Series1 := TBarSeries.Create(Chart1);
Series1.ParentChart := Chart1;
Series1.Marks.Style := smsPercent;
Chart1.LeftAxis.Maximum := 50;
Chart1.LeftAxis.Minimum := 0;
Chart1.LeftAxis.Increment := 5;
chart1.AddSeries(Series1);
series1.Clear;
for i := 0 to 5 do
begin
Series1.Add(20 + 5 * i, '¼Î±ö' + inttostr(i), clRed);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
I: Integer;
Series1: TBarSeries;
begin
Series1 := TBarSeries.Create(Chart1);
Series1.ParentChart := Chart1;
Series1.Marks.Style := smsPercent;
with Series1 do
begin
clear;
for I := 0 to 100 do
AddXY(I, Sin(I / 8),inttostr(i),clyellow);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
Series2, Series1: TBarSeries;
begin
Series1 := TBarSeries.Create(Chart1);
Series1.ParentChart := Chart1;
Series2 := TBarSeries.Create(Chart1);
Series2.ParentChart := Chart1;
Series1.Marks.Style := smsValue;
Series1.CustomBarWidth := 10;
Chart1.View3D := false;
Series1.AddBar(11, '0.1', clred);
Series1.AddBar(33, '0.2', clred);
Series1.AddBar(12, '0.3', clred);
Series1.AddBar(12, '0.4', clred);
Series1.AddBar(22, '0.5', clred);
Series1.AddBar(10, '0.6', clred);
Series2.AddXY(0, 11, '', clgreen);
Series2.AddXY(1, 33, '', clgreen);
Series2.AddXY(2, 12, '', clgreen);
Series2.AddXY(3, 12, '', clgreen);
Series2.AddXY(4, 22, '', clgreen);
Series2.AddXY(5, 10, '', clgreen);
end;
end.