Line chart
Using System;
Using System.Data;
Using System.Configuration;
Using System.Collections;
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.Imaging;
public partial class Default5:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
This. Pic ();
}
private void Pic ()
{
Test data
DataTable table = new DataTable ("Data");
DataRow Dr;
DataColumn Dc = new DataColumn ("ID", Type.GetType ("System.Int32"));
DataColumn Dc2 = new DataColumn ("Num", Type.GetType ("System.Int32"));
DataColumn Dc3 = new DataColumn ("name", Type.GetType ("System.String"));
Table. Columns.Add (DC);
Table. Columns.Add (DC2);
Table. Columns.Add (DC3);
Random rnd=new Random ();
for (int n = 0; n < n++)
{
Dr = table. NewRow ();
Dr[0] = n;
DR[1] = rnd. Next (10, 140);
DR[2] = n.tostring ();
Table. Rows.Add (DR);
}
Paint parameters
int bg_width = 450;
int bg_height = 180;
int pic_width = 450;
int pic_height = 180;
int pic_x = 6;
int pic_h = 1;
int pic_tr=5;
int pic_td = 12;
Rectangle rec = new Rectangle (50, 15, 360, 150);
Pen Pic_bolder = new Pen (color.black, 1);
Pen pic_line = new Pen (color.gray, 1);
Pen pic_data = new Pen (color.red,2);
SolidBrush brusth = new SolidBrush (Color.Blue);
point[] datapt = new point[table. Rows.Count];
int x;
int y;
for (int n = 0; n < table. Rows.Count; n++)
{
Dr=table. Rows[n];
x= (int) dr[0] * pic_x + rec. X
y= (int) dr[1] * pic_h + rec. Y
Datapt[n] = new Point (x,y);
}
Bitmap Bg = new Bitmap (Bg_width, Bg_height, Pixelformat.format24bpprgb);
Graphics Ph = Graphics.fromimage (Bg);
Ph.clear (Color.White);
Ph.drawrectangle (Pic_bolder, rec);
Draw a polyline
Ph.drawcurve (Pic_data, datapt);
Rec.
Point Spoint=new Point ();
Point Epoint=new Point ();
Draw horizontal Line
for (int n = 1; n < pic_tr; n++)
{
Cell[0] = new Point (rec. X);
Spoint.x = 0 + rec. X
SPOINT.Y = n * + rec. Y
Epoint.x = Rec. Width + Rec. X
EPOINT.Y = n * + rec. Y
Ph.drawline (Pic_line,spoint,epoint);
}
Draw Vertical Line
for (int n = 1; n < pic_td; n++)
{
Spoint.x = n * +rec. X
Spoint.y = Rec. Y
Epoint.x = n * + rec. X
Epoint.y = Rec. Height+ Rec. Y
Ph.drawline (Pic_line, Spoint, Epoint);
}
Picture Title
String Title = "Draw a polyline test";
SolidBrush brush=new SolidBrush (color.royalblue);
Ph.drawstring (Title, New Font ("Franklin Gothic Demi", fontstyle.italic), Brush, new Point (200, 0));
Ph.save ();
Bg.save (Response.outputstream, imageformat.gif);
}
}