-----------------------------------------------------------
New Message on MumbaiUserGroup
-----------------------------------------------------------
From: MilindMore
Message 2 in Discussion
Pie Chart in ASP.net
<%@ Import Namespace="System.Drawing"%>
<%@ Import Namespace="System.Drawing.Imaging"%>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Since we are outputting a Jpeg, set the ContentType appropriately
Response.ContentType = "image/jpeg";
// Create a Bitmap instance that's 468x60, and a
Graphics instance
const int width = 300, height = 300;
Bitmap objBitmap = new Bitmap(width, height);
Graphics objGraphics = Graphics.FromImage(objBitmap);
// Create a black background for the border
objGraphics.FillRectangle(new SolidBrush(Color.White), 0, 0,
width, height);
Draw3DPieChart(ref objGraphics);
// Save the image to a file
objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
// clean up...
objGraphics.Dispose();
objBitmap.Dispose();
}
// Draws a 3D pie chart where ever slice is 45 degrees in value
void Draw3DPieChart(ref Graphics objGraphics)
{
int iLoop, iLoop2;
// Create location and size of ellipse.
int x = 50;
int y = 20;
int width = 200;
int height = 100;
// Create start and sweep angles.
int startAngle = 0;
int sweepAngle = 45;
SolidBrush oibjBrush = new SolidBrush(Color.Aqua);
Random rand = new Random();
objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
//Loop through 180 back around to 135 degress so it gets drawn
// correctly.
for( iLoop = 0; iLoop <= 315; iLoop += 45)
{
startAngle = (iLoop + 180) % 360;
objBrush.Color = Color.FromArgb(rand.Next(255), rand.Next(255),
rand.Next(255));
// On degrees from 0 to 180 draw 10 Hatched brush slices to show
// depth
if((startAngle < 135) || (startAngle == 180))
{
for(iLoop2 = 0; iLoop2 < 10; iLoop2++)
objGraphics.FillPie(new HatchBrush(HatchStyle.Percent50,
objBrush.Color), x,
y + iLoop2, width, height, startAngle, sweepAngle);
}
// Displace this pie slice from pie.
if(startAngle == 135)
{
// Show Depth
for(iLoop2 = 0; iLoop2 < 10; iLoop2++)
objGraphics.FillPie(new HatchBrush(HatchStyle.Percent50,
objBrush.Color), x - 30,
y + iLoop2 + 15, width, height, startAngle,
sweepAngle);
objGraphics.FillPie(objBrush, x - 30, y + 15,
width, height, startAngle, sweepAngle);
}
else // Draw normally
objGraphics.FillPie(objBrush, x, y, width,
height, startAngle, sweepAngle);
}
}
</script>
Milind More
Programmer/Analyst
Cautel Web Solutions Pvt.Ltd.
207, Bldg No.3 ,Sector 3,
Millenium Business Park, Mahape,
Navi Mumbai - 400 701
Maharashtra - India
>From: "Ashishsinghbhu1" <[EMAIL PROTECTED]> >Reply-To: "MumbaiUserGroup" <[EMAIL
>PROTECTED]> >To: [EMAIL PROTECTED] >Subject: How to create pie charts in web applns
>>Date: Fri, 23 Jul 2004 06:21:38 -0700 >
The all new MSN Messenger! Chat with any e-mail ID! Change the way you communicate!
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]