unit Unit1;
interface
……
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TPieSeries;
……
var
Form1: TForm1;
ps: TPieSeries;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ps.Free;
ps := TPieSeries.Create(self);
ps.Clear;
ps.Repaint;
ps.CustomXRadius := 70;
ps.CustomYRadius := 70;
ps.Marks.Arrow.Visible := False;
ps.Marks.ArrowLength := -50;
ps.Marks.Transparent := True;
ps.Marks.Frame.Visible := False;
ps.Marks.Style := smsLabel;
ps.ParentChart := Chart1;
ps.AddPie(10, '第一部分', clRed);
ps.AddPie(20, '第二部分', clGreen);
ps.AddPie(5, '第三部分', clBlue);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MoveDesPart(1);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
MoveDesPart(2);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
MoveDesPart(3);
end;
procedure TForm1.MoveDesPart(i: Integer);
var
j: Integer;
begin
for j := 1 to 3 do
begin
if j = i then
begin
ps.ExplodedSlice.Value[j-1] := 10;
end
else
begin
ps.ExplodedSlice.Value[j-1] := 0;
end;
end;
end;
end.