To implement the effect diagram:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Drawing.Imaging;
Using System.Drawing;
Public partial class Default2:System.Web.UI.Page {protected void Page_Load (object sender, EventArgs e) {
string[] month = new string[12] {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; Float[] D = new float[12] {20.5f, 10.8f, 15.6f, 70.9f, 50.3f, 30.7f, N, 50.4f, 30.8f, 20}; The data of the points in the graph string[] month = new string[15] {"2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22", "24", "
26 "," 28 "," 30 "}; Float[] D = new float[15] {0.03f, 0.025f, 0.04f, 0.02f, 0.045f, 0.04f, 0.04f, 0.05f, 0.06f, 0.03f, 0.04f, 0.03f, 0.01f, 0
.02f, 0.04f};
Paint initialization Bitmap Bmap = new Bitmap (800, 800);
Graphics gph = Graphics.fromimage (BMAP); Gph.
Clear (Color.White); PointF CPT =New PointF (40, 420);//center point//x Axis Endpoint triangle pointf[] XPT = new Pointf[3] {new PointF (CPT). Y +, Cpt. Y), New PointF (CPT. Y+90, Cpt. Y-8), New PointF (CPT. Y+90, Cpt.
Y + 8)}; Y-Axis endpoint triangle pointf[] ypt = new Pointf[3] {new PointF (CPT). X, Cpt. X-15), New PointF (CPT. X-8, Cpt. X), New PointF (CPT. X + 8, Cpt.
X)}; Chart title gph. DrawString ("March generation Trend Map", New Font ("XXFarEastFont-Arial"), Brushes.black, New PointF (CPT). X +, Cpt.
X)); Draw an X-axis gph. DrawLine (Pens.black, Cpt. X, Cpt. Y, Cpt. Y+90, Cpt.
Y); Gph.
DrawPolygon (Pens.black, XPT); Gph.
FillPolygon (New SolidBrush (Color.Black), XPT); Draw x axis Title gph. DrawString ("Date (March)", New Font ("XXFarEastFont-Arial",), Brushes.black, New PointF (CPT). Y +, Cpt.
Y + 10)); Draw Y-axis gph. DrawLine (Pens.black, Cpt. X, Cpt. Y, Cpt. X, Cpt.
X); Gph.
DrawPolygon (Pens.black, ypt); Gph.
FillPolygon (New SolidBrush (Color.Black), ypt); Draw Y-axis title gph. DrawString ("Generating capacity: kwh)", New Font (" XXFarEastFont-Arial, "), Brushes.black, new PointF (0, 7)); for (int i = 1; I <=15; i++) {//Draw Y axis scale if (I < 7) {GP H.drawstring ((i * 0.01). ToString (), New Font ("XXFarEastFont-Arial"), Brushes.black, New PointF (CPT). X-30, Cpt.
Y-i * 30-6)); Gph. DrawLine (Pens.black, Cpt. X-3, Cpt. Y-i *, Cpt. X, Cpt.
Y-i * 30); ///Draw X axis item GPH. DrawString (Month[i-1], new Font ("XXFarEastFont-Arial"), Brushes.black, New PointF (CPT). X + i * 30-5, Cpt.
Y + 5)); Gph. DrawString (Month[i-1]. Substring (0, 1), New Font ("Arial", one), Brushes.black, New PointF (CPT. X + i * 30-5, Cpt.
Y + 5)); Gph. DrawString (Month[i-1]. Substring (1, 1), New Font ("Arial", one), Brushes.black, New PointF (CPT. X + i * 30-5, Cpt.
Y + 20)); if (month[i-1). Length > 2) gph. DrawString (Month[i-1]. Substring (2, 1), New Font ("Arial", one), Brushes.black, New PointF (CPT. X + i * 30-5, Cpt.
Y + 35)); Draw some gph. DrawEllipse (Pens.black, Cpt. X + i * 30-1.5f, Cpt.
Y-D[I-1] * 3000-1.5f, 3, 3); Gph. FillEllipse (New SolidBrush (Color.Black), Cpt. X + i * 30-1.5f, Cpt.
Y-D[I-1] * 3000-1.5f, 3, 3); Draw numerical gph. DrawString (D[i-1]. ToString (), New Font ("XXFarEastFont-Arial"), Brushes.black, New PointF (CPT). X + i *, Cpt.
Y-D[I-1] * (3000)); Draw a line if (i > 1) gph. DrawLine (pens.red, Cpt. X + (i-1) *, Cpt. Y-D[I-2] * 3000, CPT. X + i *, Cpt.
Y-D[I-1] *3000); ///Save output Picture//bmap.
Save (Response.outputstream, imageformat.gif);
pictureBox1.Image = Bmap;
System.IO.MemoryStream ms = new System.IO.MemoryStream (); Bmap.
Save (MS, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.clearcontent ();
Response.ContentType = "Image/gif"; Response.BinaryWrite (Ms.
ToArray ()); Gph. DisPose (); Bmap.
Dispose (); }
}
This article mainly refers to: http://blog.csdn.net/yiyiwyy326/article/details/1702979