欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

利用TCHART做分离饼形图

程序员文章站 2022-03-10 12:45:36
https://www.cnblogs.com/gaodu2003/archive/2009/06/18/1505720.html unit Unit1; interface ……type TForm1 = class(TForm) Chart1: TChart; Series1: TPieSeri ......

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.