C # Draw a statistical map encyclopedia (histogram, line chart, fan chart) _c# tutorial

Source: Internet
Author: User
Tags polyline trim

A wide variety of statistical graphics, there are columnar, line chart, fan-shaped graphs and so on, and statistical graphics to draw a lot of methods, there are flash production of statistical graphics, Crystal Report to generate statistical graphics, there are specialized graphics software production, but also programming language produced by themselves; Here we use the C # three most classic Statistical chart: Column chart , line chart and pie chart; Since it is a statistic, of course, data is needed, and the data shown here is stored in SQL Server2000, three statistical graphs are dynamically generated. One column chart I will attach the production steps, the other two statistics map directly attached to the source code.

Description: The demand is not the same, statistical graphics after the display of the effect is not the same, such as the main requirements of the column chart is to compare the number of registrations per period and the number of poor, so will put two pillars together will make comparison results at a glance. So you can be flexible to draw as needed.

I. The drawing of a histogram.

The drawing steps are as follows:

1. Define the class to use for the drawing.

int height =, width = m;
Bitmap image = New Bitmap (width, height);
Graphics g = graphics.fromimage (image);
Pen mypen = new Pen (brush, 1);

2. Draw the picture frame.

G.fillrectangle (brushes.whitesmoke, 0, 0, width, height);

3. Draw the horizontal coordinate line

for (int i = 0; i < i++) 
{
g.drawline (mypen, X, L, X,);
x = x + 40;

4. Draw the longitudinal coordinate line

for (int i = 0; i < 9; i++) 
{
g.drawline (mypen, Y, 620, y);
y = y + num;
}

5. Draw the horizontal axis value

String[] n = {"First", "second", "third", "fourth", "Whole Year"};
for (int i = 0; i < 7; i++) 
{
g.drawstring (N[i]. ToString (), font, Brushes.blue, x, 348); 
x = x + +;
}

6. Draw Ordinate values

String[] m = {"A", "the" "," "," "175", "the", "the", "Million"};
for (int i = 0; i < i++) 
{
g.drawstring (m[i). ToString (), font, Brushes.blue, y);
y = y + num;
}

7. Define the data in the array to store the statistics in the database

int[] Count1 = new INT[7]; The number of registrations that the store reads from the database
int[] Count2 = new INT[7];//storage number of passes read from database

8. Read enrolment and number of persons through the database

SqlConnection Con = new SqlConnection (
"server= (local);D atabase=committeetraining;");
Con.open ();
String cmdtxt2 = "SELECT * from # #Count 
where company= '" + ****+ "'";
SqlDataAdapter da = new SqlDataAdapter (Cmdtxt2, Con);
DataSet ds = new DataSet ();
Da. Fill (DS);

9. Storing the read data in an array

Count1[0] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count1"]. ToString ()); 
COUNT1[1] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count3"]. ToString ()); 
Count2[0] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count2"]. ToString ()); 
COUNT2[1] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count4"]. ToString ());

10. Define brushes and brushes for drawing

x =; 
Font Font2 = new System.Drawing.Font (
"Arial", fontstyle.bold);
SolidBrush MyBrush = new SolidBrush (color.red);
SolidBrush mybrush2 = new SolidBrush (color.green);

11. Draw a histogram based on the values in the array

(1) Number of enrolment in the first phase

G.fillrectangle (MyBrush, X, 340-count1[0], count1[0]);
g.DrawString (Count1[0]. ToString (), Font2, 
brushes.red, X, 340-count1[0]-15);

(2) Number of persons in the first phase

x = x +;
G.fillrectangle (MYBRUSH2, X, 340-count2[0], count2[0]);
g.DrawString (Count2[0]. ToString (), Font2, 
brushes.green, X, 340-count2[0]-15);

12. Output the graphic to the page.

System.IO.MemoryStream ms = new 
System.IO.MemoryStream ();
Image. Save (MS, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.clearcontent ();
Response.ContentType = "Image/jpeg";
Response.BinaryWrite (Ms. ToArray ());

The effect of the final bar chart:
The complete code for the bar chart:

private void CreateImage () {int height = +, width = 700;
Bitmap image = New Bitmap (width, height);

Create the Graphics class object Graphics g = graphics.fromimage (image);

try {//Empty picture background color g.clear (color.white);
Font font = new Font ("Arial", fontstyle.regular);

Font font1 = new Font ("XXFarEastFont-Arial", fontstyle.bold); LinearGradientBrush brush = new LinearGradientBrush (new Rectangle (0, 0, image. Width, image.
Height), Color.Blue, Color.blueviolet, 1.2f, true);
G.fillrectangle (brushes.whitesmoke, 0, 0, width, height);

Brush brush1 = new SolidBrush (Color.Blue); g.DrawString (This.ddlTaget.SelectedItem.Text + "" + This.ddlYear.SelectedItem.Text + "Performance Statistics column Chart", Font1, Brush, new Point
F (70, 30)); Draw a picture of the border line G.drawrectangle (new Pen (Color.Blue), 0, 0, image. Width-1, image.


HEIGHT-1);
Pen mypen = new Pen (brush, 1);
Draw Line//Draw horizontal line int x = 100;
for (int i = 0; i < i++) {G.drawline (Mypen, x, X, m); x = x + 40;}
Pen mypen1 = new Pen (color.blue, 2);
x = 60;

G.drawline (mypen1, x, N, x, 340);Draw portrait Line int y = 106;

for (int i = 0; i < 9; i++) {G.drawline (Mypen, Y, 620, y); y = y + N;} g.drawline (Mypen1, Y, 620, y);
X-axis string[] n = {"First", "second", "Phase III", "fourth", "first half", "second half", "annual Statistics"};
x = 78; for (int i = 0; i < 7; i++) {g.drawstring (N[i]. ToString (), font, Brushes.blue, x, 348);
Set the text content and output position x = x + 78;
}//y axis string[] m = {"250", "225", "200", "175", "150", "125", "100", "75", "50", "25", "0"};
y = 72; for (int i = 0; i < i++) {g.drawstring (m[i). ToString (), font, Brushes.blue, y);
Set the text content and output position y = y + 26;
} int[] Count1 = new INT[7];

int[] Count2 = new INT[7]; SqlConnection Con = new SqlConnection ("server= (local);D atabase=committeetraining; Uid=sa;
pwd=** ");
Con.open ();
String cmdtxt2 = "SELECT * from # #Count where company= '" + this.ddlTaget.SelectedItem.Text.Trim () + "'";
SqlDataAdapter da = new SqlDataAdapter (Cmdtxt2, Con);
DataSet ds = new DataSet (); Da.

Fill (DS); Count1[0] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count1"]. ToString ()); COUNT1[1] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count3"].
ToString ()); COUNT1[2] = Convert.ToInt32 (ds. Tables[0]. rows[0]["COUNT5"].
ToString ()); COUNT1[3] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count7"].

ToString ());
COUNT1[4] = count1[0] + count1[1];

COUNT1[5] = count1[2] + count1[3]; COUNT1[6] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count9"].


ToString ()); Count2[0] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count2"].
ToString ()); COUNT2[1] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count4"].
ToString ()); COUNT2[2] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count6"].
ToString ()); COUNT2[3] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count8"].

ToString ());
COUNT2[4] = count2[0] + count2[1];

COUNT2[5] = count2[2] + count2[3]; COUNT2[6] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count10"].

ToString ());
Draw a column chart.
x = 80;
Font Font2 = new System.Drawing.Font ("Arial", fontstyle.bold);
SolidBrush MyBrush = new SolidBrush (color.red);

SolidBrush mybrush2 = new SolidBrush (color.green); First phase G.fillrectanGLE (MyBrush, X, 340-count1[0], count1[0]); g.DrawString (Count1[0].

ToString (), Font2, brushes.red, X, 340-count1[0]-15);
x = x + 20;
G.fillrectangle (MYBRUSH2, X, 340-count2[0], count2[0]); g.DrawString (Count2[0].


ToString (), Font2, Brushes.green, X, 340-count2[0]-15);
Phase II X = x + 60;
G.fillrectangle (MyBrush, X, 340-count1[1], count1[1]); g.DrawString (Count1[1].


ToString (), Font2, brushes.red, X, 340-count1[1]-15);
x = x + 20;
G.fillrectangle (MYBRUSH2, X, 340-count2[1], count2[1]); g.DrawString (Count2[1].


ToString (), Font2, Brushes.green, X, 340-count2[1]-15);
Phase III x = x + 60;
G.fillrectangle (MyBrush, X, 340-count1[2], count1[2]); g.DrawString (Count1[2].

ToString (), Font2, brushes.red, X, 340-count1[2]-15);
x = x + 20;
G.fillrectangle (MYBRUSH2, X, 340-count2[2], count2[2]); g.DrawString (Count2[2].

ToString (), Font2, Brushes.green, X, 340-count2[2]-15);
Phase Fourth x = x + 60; G.fillrectangle (MyBrush, X, 340-count1[3], couNT1[3]); g.DrawString (Count1[3].

ToString (), Font2, brushes.red, X, 340-count1[3]-15);
x = x + 20;
G.fillrectangle (MYBRUSH2, X, 340-count2[3], count2[3]); g.DrawString (Count2[3].

ToString (), Font2, Brushes.green, X, 340-count2[3]-15);
First half x = x + 60;
G.fillrectangle (MyBrush, X, 340-count1[4], count1[4]); g.DrawString (Count1[4].

ToString (), Font2, brushes.red, X, 340-count1[4]-15);
x = x + 20;
G.fillrectangle (MYBRUSH2, X, 340-count2[4], count2[4]); g.DrawString (Count2[4].

ToString (), Font2, Brushes.green, X, 340-count2[4]-15);
Second half x = x + 60;
G.fillrectangle (MyBrush, X, 340-count1[5], count1[5]); g.DrawString (Count1[5].

ToString (), Font2, brushes.red, X, 340-count1[5]-15);
x = x + 20;
G.fillrectangle (MYBRUSH2, X, 340-count2[5], count2[5]); g.DrawString (Count2[5].

ToString (), Font2, Brushes.green, X, 340-count2[5]-15);
Year x = x + 60;
G.fillrectangle (MyBrush, X, 340-count1[6], count1[6]); g.DrawString (Count1[6]. ToString (),Font2, brushes.red, X, 340-count1[6]-15);
x = x + 20;
G.fillrectangle (MYBRUSH2, X, 340-count2[6], count2[6]); g.DrawString (Count2[6].


ToString (), Font2, Brushes.green, X, 340-count2[6]-15);
Draw logo Font Font3 = new System.Drawing.Font ("Arial", ten, Fontstyle.regular); G.drawrectangle (New Pen (Brushes.blue), 170, 400, 250, 50); Draw Range Box G.fillrectangle (brushes.red, 270, 410, 20, 10);

Draw Small Rectangular g.drawstring ("Enrollment number", Font3, brushes.red, 292, 408);
G.fillrectangle (Brushes.green, 270, 430, 20, 10);

g.DrawString ("Through number", Font3, Brushes.green, 292, 428);
System.IO.MemoryStream ms = new System.IO.MemoryStream (); Image.
Save (MS, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.clearcontent ();
Response.ContentType = "Image/jpeg"; Response.BinaryWrite (Ms.
ToArray ()); finally {g.dispose (); image.
Dispose ();

 }
}

Two. The drawing of the line statistic chart

Effect:

complete code for a line chart:

private void CreateImage () {int height = +, width = 700;
Bitmap image = New Bitmap (width, height);

Graphics g = graphics.fromimage (image);

try {//Empty picture background color g.clear (color.white);
Font font = new System.Drawing.Font ("Arial", 9, fontstyle.regular);
Font font1 = new System.Drawing.Font ("XXFarEastFont-Arial", fontstyle.regular);
Font Font2 = new System.Drawing.Font ("Arial", 8, fontstyle.regular); LinearGradientBrush brush = new LinearGradientBrush (new Rectangle (0, 0, image. Width, image.
Height), Color.Blue, Color.Blue, 1.2f, true);
G.fillrectangle (brushes.aliceblue, 0, 0, width, height);
Brush brush1 = new SolidBrush (Color.Blue);

Brush brush2 = new SolidBrush (Color.saddlebrown); g.DrawString (This.ddlTaget.SelectedItem.Text + "" + This.ddlYear.SelectedItem.Text + "score Statistic Line Chart", Font1, BRUSH1, new Poin
TF (85, 30)); Draw a picture of the border line G.drawrectangle (new Pen (Color.Blue), 0, 0, image. Width-1, image.

HEIGHT-1);
Pen mypen = new Pen (brush, 1);
Pen mypen2 = new Pen (color.red, 2);
Draw Line//Draw portrait line int x = 60; For(int i = 0; i < 8; i++)
{G.drawline (Mypen, x, N, x, m); x = x + 80;}
Pen mypen1 = new Pen (color.blue, 3);
x = 60;

G.drawline (mypen1, x, I, X, 340);
Draw horizontal line int y = 106;
for (int i = 0; i < i++) {g.drawline (Mypen, Y, 620, y); y = y + N;}//y = 106;

G.drawline (MYPEN1, Y-26, 620, y-26);
X-axis string[] n = {"First", "second", "Phase III", "fourth", "first half", "second half", "annual Statistics"};
x = 45; for (int i = 0; i < 7; i++) {g.drawstring (N[i]. ToString (), font, brushes.red, x, 348);
Set the text content and output position x = x + 77;
//y axis string[] m = {"220 people", "200", "175", "150", "125", "100", "75", "50", "25"};
y = 100; for (int i = 0; i < 9; i++) {g.drawstring (M[i]. ToString (), font, brushes.red, y);
Set the text content and output position y = y + 26;
} int[] Count1 = new INT[7];

int[] Count2 = new INT[7]; SqlConnection Con = new SqlConnection ("server= (local);D atabase=committeetraining; Uid=sa;
Pwd=eesoft ");
Con.open (); String cmdtxt2 = "SELECT * from # #Count where company= '" + this.ddlTaget.SelectedItem.Text.trim () + "'";
SqlDataAdapter da = new SqlDataAdapter (Cmdtxt2, Con);
DataSet ds = new DataSet (); Da.

Fill (DS); Enrollment number Count1[0] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count1"].
ToString ()); COUNT1[1] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count3"].
ToString ()); COUNT1[2] = Convert.ToInt32 (ds. Tables[0]. rows[0]["COUNT5"].
ToString ()); COUNT1[3] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count7"].

ToString ()); COUNT1[6] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count9"]. ToString ());
Full year count1[4] = Count1[0] + count1[1];


COUNT1[5] = count1[2] + count1[3]; Count2[0] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count2"].
ToString ()); COUNT2[1] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count4"].
ToString ()); COUNT2[2] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count6"].
ToString ()); COUNT2[3] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count8"].

ToString ()); COUNT2[6] = Convert.ToInt32 (ds. Tables[0]. rows[0]["Count10"]. ToString ());
Full year count2[4] = Count2[0] + count2[1];

COUNT2[5] = count2[2] + count2[3];
Show Polyline effect Font font3 = new System.Drawing.Font ("Arial", fontstyle.bold);
SolidBrush MyBrush = new SolidBrush (color.red);
point[] Points1 = new POINT[7]; Points1[0]. X = 60; Points1[0]. Y = 340-count1[0]; Starting from 106 ordinate, to (0, 0) coordinates points1[1]. X = 140; POINTS1[1].
Y = 340-count1[1]; POINTS1[2]. X = 220; POINTS1[2].
Y = 340-count1[2]; POINTS1[3]. X = 300; POINTS1[3].

Y = 340-count1[3]; POINTS1[4]. X = 380; POINTS1[4].
Y = 340-count1[4]; POINTS1[5]. X = 460; POINTS1[5].

Y = 340-count1[5]; POINTS1[6]. X = 540; POINTS1[6].
Y = 340-count1[6]; G.drawlines (Mypen2, points1); Draws a polyline//draws the number g.drawstring (Count1[0]. ToString (), Font3, Brushes.Red, points1[0].
Y-20); g.DrawString (Count1[1]. ToString (), Font3, brushes.red, 138, points1[1].
Y-20); g.DrawString (Count1[2]. ToString (), Font3, brushes.red, 218, points1[2].
Y-20); g.DrawString (Count1[3]. ToString (), Font3, brushes.red, 298, points1[3].

Y-20); g.DrawString (Count1[4]. ToString (), Font3, brushes.red, 378, points1[4].
Y-20); G.drawstrING (count1[5). ToString (), Font3, brushes.red, 458, points1[5].

Y-20); g.DrawString (Count1[6]. ToString (), Font3, brushes.red, 538, points1[6].

Y-20);
Pen Mypen3 = new Pen (color.green, 2);
point[] points2 = new POINT[7]; Points2[0]. X = 60; Points2[0].
Y = 340-count2[0]; POINTS2[1]. X = 140; POINTS2[1].
Y = 340-count2[1]; POINTS2[2]. X = 220; POINTS2[2].
Y = 340-count2[2]; POINTS2[3]. X = 300; POINTS2[3].

Y = 340-count2[3]; POINTS2[4]. X = 380; POINTS2[4].
Y = 340-count2[4]; POINTS2[5]. X = 460; POINTS2[5].

Y = 340-count2[5]; POINTS2[6]. X = 540; POINTS2[6].
Y = 340-count2[6]; G.drawlines (Mypen3, points2); Draw a polyline//draw through the number of g.drawstring (Count2[0]. ToString (), Font3, Brushes.green, points2[0].
Y-15); g.DrawString (Count2[1]. ToString (), Font3, Brushes.green, 131, points2[1].
Y-15); g.DrawString (Count2[2]. ToString (), Font3, Brushes.green, 221, points2[2].
Y-15); g.DrawString (Count2[3]. ToString (), Font3, Brushes.green, points2[3].

Y-15); g.DrawString (Count2[4]. ToString (), FONt3, Brushes.green, 381, points2[4].
Y-15); g.DrawString (Count2[5]. ToString (), Font3, Brushes.green, 461, points2[5].

Y-15); g.DrawString (Count2[6]. ToString (), Font3, Brushes.green, 541, points2[6].

Y-15); Draw Identification G.drawrectangle (new Pen (brushes.red), 180, 390, 250, 50); Draw Range Box G.fillrectangle (brushes.red, 270, 402, 20, 10);

Draw Small Rectangular g.drawstring ("Enrollment number", Font2, brushes.red, 292, 400);
G.fillrectangle (Brushes.green, 270, 422, 20, 10);

g.DrawString ("Through number", Font2, Brushes.green, 292, 420);
System.IO.MemoryStream ms = new System.IO.MemoryStream (); Image.
Save (MS, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.clearcontent ();
Response.ContentType = "Image/jpeg"; Response.BinaryWrite (Ms.
ToArray ()); finally {g.dispose (); image.
Dispose ();

 }
}

Three. The drawing of Sector statistics chart

Pie chart Complete code:

private void CreateImage () {//The connection string is specified as a constant SqlConnection Con = new SqlConnection ("server=" (local); database=committeetraining; Uid=sa;
pwd=** ");
Con.open (); string cmdtxt = selectstring; "SELECT * from # #Count";
SqlCommand Com = new SqlCommand (Cmdtxt, Con);
DataSet ds = new DataSet ();
SqlDataAdapter Da = new SqlDataAdapter (Cmdtxt, Con);
Da.fill (DS);
Con.close ();

Float total = 0.0f, Tmp; Converted to single precision. It can also be written as convert.toint32 total = Convert.tosingle (ds). Tables[0].

Rows[0][this.count[0]]); Total=convert.tosingle (ds. Tables[0].
Rows[0][this.count[0]]);
Sets the font, fonttitle the font fontlegend = new Font ("Verdana", 9) for the main title;

Font fonttitle = new Font ("Verdana", ten, FontStyle.Bold);
Background width int width = 350;
int bufferspace = 15; int legendheight = Fontlegend. Height * + bufferspace; Height int titleheight = fonttitle.
Height + bufferspace;
int height = width + legendheight + titleheight + bufferspace;//white background high int pieheight = width;

Rectangle pierect = new Rectangle (0, Titleheight, width, pieheight);Plus a variety of random color ArrayList colors = new ArrayList ();
Random rnd = new Random (); for (int i = 0; i < 2; i++) colors. ADD (New SolidBrush (COLOR.FROMARGB) (Rnd. Next (255), Rnd. Next (255), Rnd.

Next (255)));
Create a Bitmap instance Bitmap Objbitmap = new Bitmap (width, height);

Graphics objgraphics = Graphics.fromimage (Objbitmap); Draw a white background objgraphics.

FillRectangle (New SolidBrush (Color.White), 0, 0, width, height); Draw a bright yellow background objgraphics.

FillRectangle (New SolidBrush (Color.beige), pierect);

The following is a Gao figure (there are several rows of row painting several) float currentdegree = 0.0f; Drawing through the number of objgraphics. FillPie ((SolidBrush) colors[1], Pierect, Currentdegree, Convert.tosingle (ds. Tables[0].
ROWS[0][THIS.COUNT[1]]/total * 360); Currentdegree + = Convert.tosingle (ds. Tables[0].

ROWS[0][THIS.COUNT[1]]/total * 360; The number of objgraphics in the pie chart was not passed. FillPie ((SolidBrush) colors[0], Pierect, Currentdegree, (Convert.tosingle (ds. Tables[0]. ROWS[0][THIS.COUNT[0]])-(Convert.tosingle ds. Tables[0].
ROWS[0][THIS.COUNT[1])))/total * 360); Currentdegree + + (convert.tosingle(ds. Tables[0]. ROWS[0][THIS.COUNT[0]])-(Convert.tosingle ds. Tables[0].


ROWS[0][THIS.COUNT[1]))/total * 360;
The following is the generated main heading SolidBrush Blackbrush = new SolidBrush (color.black);
SolidBrush Bluebrush = new SolidBrush (Color.Blue);
string title = "Office Unit performance Statistics pie chart:" + "n \ n";
StringFormat StringFormat = new StringFormat ();
Stringformat.alignment = Stringalignment.center;

Stringformat.linealignment = Stringalignment.center; Objgraphics.

DrawString (title, Fonttitle, Blackbrush, New Rectangle (0, 0, Width, titleheight), StringFormat); List each field with the number of objgraphics.

DrawRectangle (New Pen (Color.Red, 2), 0, height + 10-legendheight, width, legendheight + 50); Objgraphics. DrawString ("----------------Statistical information------------------", Fontlegend, Bluebrush, Height-legendheight + fontlegend.
Height * 1 + 1); Objgraphics. DrawString ("Statistic unit:" + This.ddlTaget.SelectedItem.Text, Fontlegend, Blackbrush, Height-legendheight + fontlegend.)
Height * 3 + 1); Objgraphics. DrawString ("Year of Statistics:" + This.ddlYear.SelEcteditem.text, Fontlegend, Blackbrush, Height-legendheight + fontlegend.
Height * 4 + 1); Objgraphics. DrawString ("Number of Statistics:" + This.ddlSpan.SelectedItem.Text, Fontlegend, Blackbrush, Height-legendheight + fontlegend.)

Height * 5 + 1); Objgraphics. FillRectangle ((SolidBrush) colors[1], 5,height-legendheight + fontlegend.
Height * 8 + 1, 10, 10); Objgraphics. DrawString ("Total enrolment:" + convert.tostring (Convert.tosingle) (ds. Tables[0]. Rows[0][this.count[0])), Fontlegend, Blackbrush, Height-legendheight + fontlegend.
Height * 7 + 1); Objgraphics. FillRectangle (SolidBrush) colors[0], 5, Height-legendheight + fontlegend.
Height * 9 + 1, 10, 10); Objgraphics. DrawString ("Through total number:" + convert.tostring (Convert.tosingle) (ds. Tables[0]. ROWS[0][THIS.COUNT[1])), Fontlegend, Blackbrush, Height-legendheight + fontlegend.
Height * 8 + 1); Objgraphics. DrawString ("Failed number:" + (Convert.tosingle) (ds. Tables[0]. ROWS[0][THIS.COUNT[0]])-(Convert.tosingle ds. Tables[0]. ROWS[0][THIS.COUNT[1])), FOntlegend, Blackbrush, Height-legendheight + fontlegend.

Height * 9 + 1); Objgraphics. DrawString ("Pass rate:" + convert.tostring (Convert.tosingle) (ds. Tables[0]. ROWS[0][THIS.COUNT[1]]/Convert.tosingle (ds. Tables[0]. Rows[0][this.count[0]]) + "%", Fontlegend, Blackbrush, Height-legendheight + fontlegend.

Height * 10 + 1);
Response.ContentType = "Image/jpeg"; Objbitmap.
Save (Response.outputstream, System.Drawing.Imaging.ImageFormat.Jpeg); Objgraphics.
Dispose (); Objbitmap.

Dispose ();

 }

  Here the statistical map directly output to the Web page, the above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud-dwelling community.

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.