asp.net uses GDI + to draw the 3D Pie chart introductory article source code

Source: Internet
Author: User
Asp.net| Pie chart topn3dpie.aspx
------------------
<%@ Page language= "C #" codebehind= "Topn3dpie.aspx.cs" autoeventwireup= "false" inherits= "Yeefly.topn3dpie"%>

Topn3dpie.aspx.cs
-----------------
Using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Web;
Using System.Web.SessionState;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.HtmlControls;
Using System.Drawing.Imaging;
Using System.Drawing.Drawing2D;
Using System.IO;

Namespace Yeefly
{
<summary>
A summary description of Graph.
</summary>
public class Topn3dpie:System.Web.UI.Page
{
private void Page_Load (object sender, System.EventArgs e)
{
Response.ContentType = "Image/jpeg";
const int width = $, height = 300;
int x =, y = 50;

int piewidth = Pieheight =, Pieshadow = 15;
Int[] Arrvote = {70,90,80,20,60,40};
Random ORan = new Random ();


Bitmap Objbitmap = new Bitmap (width, height);
Graphics objgraphics = Graphics.fromimage (Objbitmap);
Objgraphics.drawrectangle (New Pen (Color.Black), 0,0,width,height);
Objgraphics.fillrectangle (New SolidBrush (Color.White), 1, 1,width-2, height-2);
SolidBrush Objbrush = new SolidBrush (Color.Blue);
Objgraphics.smoothingmode = Smoothingmode.antialias;

int icurrentpos = 0;

Color[] Arrcolor = {color.red,color.red,color.red,color.red,color.red,color.red};

for (int i = arrvote.length-1 i >= 0; i--)
{
Arrcolor[i] = Color.FromArgb (Oran.next (255), Oran.next (255), Oran.next (255));
}

for (int i = arrvote.length-1 i >= 0; i--)
{
Objbrush.color = Arrcolor[i];
for (int iLoop2 = 0; iLoop2 < Pieshadow; iloop2++)
Objgraphics.fillpie (New HatchBrush (Hatchstyle.percent50,objbrush.color), x, Y + iLoop2, piewidth, Pieheight, Icurrentpos, Arrvote[i]);
Icurrentpos + = Arrvote[i];
}

Icurrentpos = 0;
for (int i = arrvote.length-1 i >= 0;i--)
{
Objbrush.color = Arrcolor[i];
Objgraphics.fillpie (objbrush,x, y, Piewidth, Pieheight, Icurrentpos, Arrvote[i]);
Icurrentpos + = Arrvote[i];
}

Objbitmap.save (Response.outputstream, imageformat.jpeg);
Clean up ...
Objgraphics.dispose ();
Objbitmap.dispose ();
}

Code generated #region the Web forms Designer
Override protected void OnInit (EventArgs e)
{
//
CodeGen: This call is required for the ASP.net Web forms Designer.
//
InitializeComponent ();
Base. OnInit (e);
}

<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
This. Load + = new System.EventHandler (this. Page_Load);
}
#endregion
}
}




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.