C # Display Line chart

Source: Internet
Author: User

parameter is an array, which is the specific data for the line chart, and can be entered at 40 points,

And then it shows up on the PictureBox1,

Display Line chart method,//choose=1 display in Pic_focus; choose=0 Display in pic_nervous public void broken_line (params int [] D) {//painting
            Figure initialization Bitmap Bmap = new Bitmap (1600, MB);//150 Graphics = gph graphics.fromimage (BMAP); Gph.

            Clear (Color.White); PointF CPT = new PointF (40, 90);//center point 40,120 pointf[] XPT = new Pointf[3] {new PointF (CPT). Y +, Cpt. Y), New PointF (CPT. Y, Cpt. Y-8), New PointF (CPT. Y, Cpt. Y + 8)};//x Axis 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)};//y Axis triangle//gph. DrawString ("A product monthly production chart for a Factory", New Font ("XXFarEastFont-Arial"), Brushes.black, New PointF (CPT). X+60, Cpt. x));//Chart title//x axis GPH. DrawLine (Pens.black, Cpt. X, Cpt. Y, Cpt. y+600, Cpt.
            Y); Do not draw the arrow, so the following two lines to remove GPH. DrawString ("Time", New Font ("XXFarEastFont-Arial"), Brushes.black, New PointF (CPT). Y + 10+1000Cpt.

            Y + 10)); Draw Y-axis gph. DrawLine (Pens.black, Cpt. X, Cpt. Y, Cpt.
            
            X, 10);
                for (int i = 1; I <= i++)//Originally here 12 {//Draw Y axis scale if (I < 11)/originally this is 11 {gph. DrawString ((i * 10). ToString (), New Font ("Song Body", 8), Brushes.black, New PointF (CPT). X-30, Cpt.
                    Y-i * 8-6)); Gph. DrawLine (Pens.black, Cpt. X-3, Cpt. Y-i * 8, Cpt. X, Cpt. Y-i * 8),//tick 1 small Horizontal}//Draw 3 demarcation line (own written) gph. DrawLine (Pens.black, Cpt. X, Cpt. Y-4 * 8, Cpt. Y + 1120, Cpt.
                Y-4 * 8); Gph. DrawLine (Pens.black, Cpt. X, Cpt. Y-7 * 8, Cpt. Y + 1120, Cpt.
                Y-7 * 8); Gph. DrawLine (Pens.black, Cpt. X, Cpt. y-10* 8, Cpt. Y + 1120, Cpt.

                y-10* 8); Draw the X-axis item/point GPH. DrawEllipse (Pens.black, Cpt. X + i * 30-1.5f, Cpt. Y-D[I-1] * 0.8f-1.5f, 3, 3); Gph. FillEllipse (New SolidBrush (Color.Black), Cpt. X + i * 30-1.5f, Cpt.
                Y-D[I-1] * 0.8f-1.5f, 3, 3); Draw the value if (d[i-1]!=0) gph. DrawString (D[i-1]. ToString (), New Font ("XXFarEastFont-Arial"), Brushes.black, New PointF (CPT). X + i *, Cpt.
                Y-D[I-1] * 0.8f)); Pp.
                Image = Bmap;
                Return Draw a line if (i > 1) gph. DrawLine (pens.red, Cpt. X + (i-1) *, Cpt. Y-D[I-2] * 0.8f, Cpt. X + i *, Cpt.
            Y-D[I-1] * 0.8f); ///Save output Picture//bmap.
             Save (Response.outputstream, imageformat.gif); picturebox1.
        Image = Bmap; }


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.