C#绘制饼图的简单方法

来源:互联网 发布:架设代理服务器软件 编辑:程序博客网 时间:2024/05/07 10:47
Graphics.FillPie 方法

参数

brush
确定填充特性的 Brush 对象。
x
边框左上角的 x 坐标,该边框定义扇形区所属的椭圆。
y
边框左上角的 y 坐标,该边框定义扇形区所属的椭圆。
width
边框的宽度,该边框定义扇形区所属的椭圆。
height
边框的高度,该边框定义扇形区所属的椭圆。
startAngle
从 x 轴沿顺时针方向旋转到扇形区第一个边所测得的角度(以度为单位)。
sweepAngle
startAngle 参数沿顺时针方向旋转到扇形区第二个边所测得的角度(以度为单位)。
   //开始绘制
   float startAngle=270;
   SolidBrush MyBrush;
   Graphics g=this.pnlPctImg.CreateGraphics();
   g.Clear(this.BackColor);
   MyBrush=new SolidBrush(Color.Red);
   g.FillPie(MyBrush,2,2,120,120,startAngle,(a/100)*360);
   startAngle+=(a/100)*360;
   MyBrush=new SolidBrush(Color.Blue);
   g.FillPie(MyBrush,2,2,120,120,startAngle,(b/100)*360);
   startAngle+=(b/100)*360;
   MyBrush=new SolidBrush(Color.Green);
   g.FillPie(MyBrush,2,2,120,120,startAngle,(c/100)*360);
   startAngle+=(c/100)*360;
   MyBrush=new SolidBrush(Color.Pink);
   g.FillPie(MyBrush,2,2,120,120,startAngle,(d/100)*360);
   g.Dispose();
 
原创粉丝点击