首页

c# 饼形图分析公司男女比例 附源码

c#

2020-8-30

        private void ShowPic(string SexCode, float f)
        {
            Graphics g = this.panel1.CreateGraphics();					//通过panel1控件创建一个Graphics对象
            Pen p = new Pen(new SolidBrush(Color.Blue));					//创建画笔
            Point p1 = new Point(0, 0);								//创建Point对象
            Size s = new Size(this.panel1.Width, this.panel1.Height);			//创建Size对象
            Rectangle trct = new Rectangle(p1, s);						//创建Rectangle对象
            g.FillEllipse(new SolidBrush(Color.Red), trct);					//绘制椭圆
            g.FillPie(new SolidBrush(Color.Blue), trct, 180, f * 360);			//绘制扇形
            Graphics ginfo = this.panel2.CreateGraphics();					//通过panel2控件创建一个Graphics对象
            Font font = new Font("宋体", 10, FontStyle.Regular);			//设置字体
            //绘制性别
            ginfo.DrawString(SexCode   " "   f.ToString().Substring(0, 4), font, new SolidBrush(Color.Blue), 0, 5);
            ginfo.DrawString("女"   " "   (1.0 - Convert.ToDouble(f.ToString().Substring(0, 4))).ToString().Substring(0, 4), font, new SolidBrush(Color.Red), 0, 25);										//绘制比例
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Conn();
            using (cmd = new SqlCommand("SELECT sex,COUNT(sex) num FROM tb_sex group by sex", con))
               {
                   SqlDataReader dr=cmd.ExecuteReader();
                   string[] str = new string[2];
                   int i=0;
                   while (dr.Read())
                   {
                       str[i] = dr[0].ToString()   ","   dr[1].ToString();
                       i  ;
                   }
                   float N = Convert.ToInt16(str[0].Substring(2))   Convert.ToInt16(str[1].Substring(2));
                   float f =  Convert.ToInt16(str[0].Substring(2))/N;
                   ShowPic(str[0].Substring(0,1), f);
               }
        }
资源下载此资源下载价格为2D币(VIP免费),请先
资源文件列表
CAnalyseSex.sln , 923
CAnalyseSex.suo , 18432
CAnalyseSex/CAnalyseSex.csproj , 4026
CAnalyseSex/Frm_Main.cs , 2685
CAnalyseSex/Frm_Main.designer.cs , 3417
CAnalyseSex/Frm_Main.resx , 5814
CAnalyseSex/obj/Debug/CAnalyseSex.csproj.FileListAbsolute.txt , 2937
CAnalyseSex/obj/Debug/DesignTimeResolveAssemblyReferences.cache , 789
CAnalyseSex/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache , 7158
CAnalyseSex/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll , 4608
CAnalyseSex/obj/Debug/└√╙├▒²╨══╝╖╓╬÷╣½╦╛─╨┼«▒╚┬╩.csproj.FileListAbsolute.txt , 1990
CAnalyseSex/Program.cs , 495
CAnalyseSex/Properties/AssemblyInfo.cs , 1354
CAnalyseSex/Properties/Resources.Designer.cs , 2862
CAnalyseSex/Properties/Resources.resx , 5612
CAnalyseSex/Properties/Settings.Designer.cs , 1111
CAnalyseSex/Properties/Settings.settings , 249
└√╙├▒²╨══╝╖╓╬÷╣½╦╛─╨┼«▒╚┬╩.suo , 26624
没有账号? 忘记密码?

社交账号快速登录