• 使用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>

  • 相关阅读:
    [Algorithm] Universal Value Tree Problem
    [HTML5] Using the focus event to improve navigation accessibility (nextElementSibling)
    [Javascript] Coding interview problem: Scheduler functional way
    [Algorithm] Tree: Lowest Common Ancestor
    [NPM] Execute Code from a Remote GitHub Branch with npx
    hdu 4740
    通过网页实现软件的布局
    STL 统计vector容器中指定对象元素出现的次数:count()与count_if()算法
    善待自己生存的空间
    青春散场
  • 原文地址:https://www.cnblogs.com/zyosingan/p/1362554.html
Copyright © 2020-2023  润新知