利用TCHART做分离饼形图
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.