C # drawing diagram ideas: Because the drawing is in the upper left corner as the starting point, so the curve is drawn after the right is the opposite direction
1. Draw a graph (rotate to a positive direction after the drawing is finished)
2. Draw a background grid
3. Merging layers
response.clear (); Load test data datatable tbl = new DataTable (); Tbl. Columns.Add ("Price"); Tbl. Columns.Add ("Count"); Random ran = new Random (); DataRow row = null; int count = 0; int price = 0; for (int i = 0; i < i++) {row = tbl. NewRow (); row["Price" = ran. Next (0, 250); Count = ran. Next (0, 800); if (I!= 0) {if (Count < Convert.ToInt32 (TBL). rows[i-1]["Count"]) {i--; continue}} row["Count" = count; Tbl. Rows.Add (row); int width = 800; int height = 270; Picture curve Bitmap bmp = new Bitmap (width, height); Pen pen = new Pen (color.black); Graphics Grap = graphics.fromimage (BMP); Point[] points = new point[tbl. Rows.Count]; int _x; int _y; curvilinear coordinate array for (int i = 0; i < tbl. Rows.Count; i++) {int. TryParse (TBL. rows[i]["Price"]. ToString (), out _x); Int. TryParse (TBL. rows[i]["Count"]. ToString (), out _y); Points[i] = new Point (_y, _x); } grap. DrawLines (pen, points); Draw a curve bmp. RotateFlip (ROTATEFLIPTYPE.ROTATE180FLIPX); Reverse picture//Draw background pen PENBG = new Pen (color.black, 1); Bitmap BMPBG = new Bitmap (width, height); Graphics GRAPBG = Graphics.fromimage (BMPBG); Draw the horizontal for (int j = 0, i = 5; I >= 0; I--, j + +) {int var = i *; grapbg. DrawString (Convert.ToString (J *), New Font ("XXFarEastFont-Arial"), Brushes.black, New PointF (var-3)); GRAPBG. DrawLine (PENBG, new point (= Var), new Point (Var)); ///Draw longitudinal for (int j = 0, i = 0; i < 8; i++, J + +) {int var = i * +; GRAPBG. DrawLine (PENBG, New Point (Var, 0), New Point (Var, 250)); if (j = = 0) {continue} GRAPBG. DrawString (Convert.ToString (J *), New Font ("XXFarEastFont-Arial",), Brushes.black, New PointF (VAR-10, 250)); ///Merge layer GRAPBG. DrawImage (BMP, New Point (45,-19)); Save to storage stream System.IO.MemoryStream ms = new System.IO.MemoryStream (); BMPBG. Save (MS, System.Drawing.Imaging.ImageFormat.Png); Output content Response.OutputStream.Write (Ms. GetBuffer (), 0, (int) Ms. Length); Response.End ();