ASP tutorial. NET Drawing Curve Program
*/
using System;
Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.web.ui.webcontrols.webparts;
Using System.Web.UI.HtmlControls;
Using System.Drawing;
Using System.Drawing.Drawing2D;
public partial class _default:system.web.ui.page
{
protected void Page_Load (object sender, EventArgs e)
{
This.createimage ();
}
private void CreateImage ()
{
int height = +, width = 800;
Bitmap image = New Bitmap (width, height);
Graphics graphics = graphics.fromimage (image);
StringFormat SF = new StringFormat ();
Try
{
Graphics.clear (Color.White);
Font font = new Font ("Arial", 9, fontstyle.regular);
Font font1 = new Font ("XXFarEastFont-Arial", fontstyle.regular);
LinearGradientBrush brush = new LinearGradientBrush (new rectangle (0, 0, Image.width, image.height), Color.Blue, Color.Blue, 1.2f, true);
Graphics.FillRectangle (brushes.whitesmoke, 0, 0, width, height);
Brush BRUSH1 = new SolidBrush (Color.Blue);
String p_str_sum = "2010-11-10";
Graphics.DrawString ("Analysis of seniority ratio", font1, Brush1, New PointF (130, 30));
Draw a picture's border line
Graphics.drawrectangle (New Pen (Color.Blue), 0, 0, image.width-1, image.height-1);
Pen mypen = new Pen (brush, 1);
Draw horizontal Lines
int x = 100;
for (int i = 0; i < i++)
{
Graphics.drawline (Mypen, x, N, x, 340);
x = x + 20;
}
Pen mypen1 = new Pen (color.blue, 2);
Pen mypen2 = new Pen (color.red, 2);
Graphics.drawline (Mypen1, x-480, x-480, 340);
Draw portrait Lines
int y = 106;
for (int i = 0; i < i++)
{
Graphics.drawline (Mypen, y, N, y);
y = y + 26;
}
Graphics.drawline (Mypen1, y, N, y);
X axis
String[] n = {"0-3 months", "more than 3 months", "more than 6 months", "1 Years", "2 Years", "3 Years", "4 Years", "5 Years", "6 Years", "7 Years", "8 Years", "9 years", "10", "11", "12", "13", "14", "15", "16", "17"};
x = 35;
for (int i = 0; i < i++)
{
Graphics.DrawString (n[i].tostring (), font, brushes.red, x, 348); Set text content and output location
x = x + 40;
}
Y axis
String[] m = {"20 people", "40", "60", "80", "100", "120", "140",
"160 people", "180", "200", "220", "240", "260", "280", "300", "320", "340",
"360 People", "380 people", "400", "600"};
y = 98;
for (int i = 0; i < i++)
{
Graphics.DrawString (m[i].tostring (), font, brushes.red, y); Set text content and output location
y = y + 26;
}
Int[] count = new INT[20];
String p_year = "2010-11-10";
Qldataadapter Myda = new SqlDataAdapter (P_year, Sqlcon);
DataSet myds = new DataSet ();
Myda.fill (myds);
for (int i = 0; i < i++)
{
Count[i] = i;
}
SolidBrush MyBrush = new SolidBrush (color.red);
point[] MyPoint = new POINT[20];
mypoint[0].x = 30; MYPOINT[0].Y = 340-count[0];
mypoint[1].x = 50; MYPOINT[1].Y = 340-count[1];
mypoint[2].x = 70; MYPOINT[2].Y = 340-count[2];
mypoint[3].x = 90; MYPOINT[3].Y = 340-count[3];
mypoint[4].x = 110; MYPOINT[4].Y = 340-count[4];
mypoint[5].x = 130; MYPOINT[5].Y = 340-count[5];
mypoint[6].x = 150; MYPOINT[6].Y = 340-count[6];
mypoint[7].x = 170; MYPOINT[7].Y = 340-count[7];
mypoint[8].x = 190; MYPOINT[8].Y = 340-count[8];
mypoint[9].x = 210; MYPOINT[9].Y = 340-count[9];
mypoint[10].x = 230; MYPOINT[10].Y = 340-count[10];
mypoint[11].x = 250; MYPOINT[11].Y = 340-count[11];
mypoint[12].x = 270; MYPOINT[12].Y = 340-count[12];
mypoint[13].x = 290; MYPOINT[13].Y = 340-count[13];
mypoint[14].x = 310; MYPOINT[14].Y = 340-count[14];
mypoint[15].x = 330; MYPOINT[15].Y = 340-count[15];
mypoint[16].x = 350; MYPOINT[16].Y = 340-count[16];
mypoint[17].x = 370; MYPOINT[17].Y = 340-count[17];
mypoint[18].x = 390; MYPOINT[18].Y = 340-count[18];
mypoint[19].x = 420; MYPOINT[19].Y = 340-count[19];
Graphics.DrawString ("", New Font ("XXFarEastFont-Arial,"), New SolidBrush (color.red), new Rectangle (0, 360,,), SF);
Graphics.drawlines (Mypen2, MyPoint); Draw a polyline
System.IO.MemoryStream mstream = new System.IO.MemoryStream ();
Image.Save (Mstream, system.drawing.imaging.imageformat.gif);
Response.clearcontent ();
Response.ContentType = "Image/gif";
Response.BinaryWrite (Mstream.toarray ());
}
Finally
{
Graphics.dispose ();
Image.dispose ();
}
}
}