zoukankan      html  css  js  c++  java
  • 使用ASP.NET画饼状图

    <%@ Page  ContentType  =  "image/gif"%>  
    <%@ Import  Namespace  =  "System.Drawing"  %>  
    <%@ Import  Namespace  =  "System.Drawing.Imaging"  %>  
    <%@ Import Namespace="System.Drawing.Text" %>
    <script  runat="server"  language="C#">  

    void  Page_Load  (Object  sender,  EventArgs  e)  
    {  
              Bitmap  objBitmap;  
              Graphics  objGraphics;  
               
               //建立画布
              objBitmap  =  new  Bitmap(400,  440);  
              objGraphics  =  Graphics.FromImage(objBitmap);  
             
              //填充背景
              objGraphics.Clear(Color.White);

               //绘制饼状图
              Pen p=new Pen(Color.Yellow,0);
              Rectangle rect=new Rectangle(10,10,380,380);
              objGraphics.DrawEllipse(p,rect);
             
              //填充饼状图
              Brush b1=new SolidBrush(Color.Red);
              Brush b2=new SolidBrush(Color.Green);
              Brush b3=new SolidBrush(Color.Blue);
              objGraphics.FillPie(b1,rect,0f,120f);
              objGraphics.FillPie(b2,rect,120f,120f);
              objGraphics.FillPie(b3,rect,240f,120f);
             
              //绘制文字
              FontFamily fontfml=new FontFamily(GenericFontFamilies.Serif);
              Font font=new Font(fontfml,20);
              SolidBrush brush=new SolidBrush(Color.Blue);
              objGraphics.DrawString("ASP.NET C# 绘图示例",font,brush,50,400);

              //输出并保存图象
              objBitmap.Save(Response.OutputStream,  ImageFormat.Gif);  
              objBitmap.Save(Server.MapPath("x.jpg"),  ImageFormat.Jpeg);  
             
              //结束绘制
              objBitmap.Dispose();  
              objGraphics.Dispose();  
    }  
    </script>  

    <html>
    <head runat="server">
       <title>无标题页</title>
    </head>
    <body>
       <form id="form1" runat="server">
       <div>
       
       </div>
       </form>
    </body>
    </html>

  • 相关阅读:
    创新工场 笔试1
    C++的异常处理
    阿里笔试题2
    阿里笔试题1
    控制CPU占用率曲线
    再探结构体字节对齐问题
    1401
    pancake sort的几个问题
    CF198 D2
    谨慎设计一个单例类
  • 原文地址:https://www.cnblogs.com/zyosingan/p/1362554.html
Copyright © 2011-2022 走看看