// Painted with ASP.NET (available for various voters)
/ / ASP compared to ASP.NET with more powerful features, using GDI can easily implement a lot of graphics features that have not been possible.
// First, build a library of library in C: / Chinese, and build a table title.
// Built two fields, Title (CHAR type), Point (INT)
// very satisfied 281
// Comparative satisfaction 297
// also make up 166
// Not satisfied with 416
// I also wrote the part of the painting chart and bar chart, which is currently writing all of them into a class. Can you need to contact me: Mailto: Ouyang76@263.net
<% @ Page language = "c #"%>
<% @ Import namespace = "system.data"%>
<% @ import namespace = "system.data.oledb"%>
<% @ import namespace = "system.drawing"%>
<% @ import namespace = "system.drawing.imaging"%>
Public void Page_Load (Object Obj, Eventargs E)
{
/ / Specify the connection string as a constant
Const string strconn = "provider = microsoft.jet.Oledb.4.0;"
"DATA SOURCE = C: //Mess.mdb";
OLEDBCONNECTION CONN = New OLEDBCONNECTION (STRCONN);
Cn.open ();
String SQL = "SELECT * from Title";
OLEDBCOMMAND CMD = New OLEDBCOMMAND (SQL, CONN);
DataSet DS = New Dataset ();
OLEDBDataAdapter Adapter1 = New OLEDBDataAdapter (CMD);
Adapter1.fill (DS);
CONN.CLOSE ();
FLOAT TOTAL = 0.0f, TMP;
ILOOP;
For (iLOOP = 0; iLoop { TMP = convert.tosingle (ds.tables [0] .rows [iLoop] ["Point"]); // Convert to single-precision, vote is impossible to vote. Can also be written into convert.toint32 Total = TMP; } //Response.write (TOTOTOSTRING (TOTAL)); Font Fontlegend = New Font ("Verdana", 9), Fonttitle = New Font ("Verdana", 10, FontStyle.Bold); // Setting the font // fonttitle-based font Int width = 230; // white background wide Const int bufferspa = 15; INT legendheight = fontlegend.Height * (ds.tables [0] .rows.count 1) bufferspace; INT TitleHeight = fonttitle.height bufferspace; int Height = Width LegendHeight TitleHeight Bufferspace; // White Background High INT PIEHEIGHT = Width; Rectangle Pierat = New Rectangle (0, TitleHeight, Width, PieHeight); / / Plus a variety of random colors Arraylist colors = new arraylist (); Random rnd = new random (); For (iLOOP = 0; iLoop Colors.add (New Solidbrush (Color.Fromargb (Rnd.Next (255), Rnd.Next (255), Rnd.Next (255))))); Bitmap objbitmap = new bitmap (width, height); // Create a Bitmap instance // bitmap objbitmap = new bitmap (230, 500); // Create a Bitmap instance Graphics Objgraphics = graphics.fromimage (objbitmap); Objgraphics.FillRectangle (New Solidbrush (Color.White), 0, 0, Width, Height); // Draw a white background Objgraphics.FillRectangle (New Solidbrush (Color.lightyellow), Pierect); // Draw a bright yellow background / / The following is a painting chart (several rows of row paintings) Float currentdegree = 0.0f; For (iLOOP = 0; iLoop { Objgraphics.Fillpie (Solidbrush) Colors [iLOOP], Pierect, Currentdegree, Convert.tosingle (DS.Tables [0] .Rows [iLoop] ["Point"]) / TOTAL * 360); Currentdegree = Convert.TOSINGLE (DS.Tables [0] .rows [iLOOP] ["Point"]) / Total * 360; } // - The following is the master title Solidbrush BlackBrush = New Solidbrush (Color.Black); String Title = "This" programmer's big camp "launched a special issue, is you satisfied with the special issue?" StringFormat stringFormat = new stringFormat (); StringFormat.Alignment = stringalignment.center; StringFormat.LineAlignment = stringalignment.center; Objgraphics.drawstring (Title, Fonttitle, BlackBrush, New Rectangle (0, 0, Width, TitleHEHT), STRINGMMAT; // list the number of votes and votes Objgraphics.drawRectangle (New Pen (Color.Black, 2), 0, Height - LegendHeight, Width, LegendHeight; For (iLOOP = 0; iLoop { Objgraphics.FillRectangle (Solidbrush) Colors [iLoop], 5, Height - LegendHeight Fontlegend.Height * iLoop 5, 10, 10); Objgraphics.drawstring ((String) DS.Tables [0] .rows [iLoop] ["Title"]) "-" Convert.Tostring (DS.TABLES [0] .rows [iLoOP] ["Point"] ), Fontlegend, BlackBrush, 20, Height - LegendHeight Fontlegend.Height * iLoop 1); } // Objgraphics.drawstring ("Total votes are:" Convert.TOString (Total), Fontlegend, BlackBrush, 5, Height - Fontlegend.HeiGHT); // Image Total Height - The height of a line of fonts, is the bottom of the most row of fonts (Height - Fontlegend.height) Response.ContentType = "image / jpeg"; Objbitmap.save (response.outputstream, imageformat.jpeg); //objbitmap.save ("myyyyyyyyyy.jpg ", imageformat.jpeg; // Output to the file Objgraphics.dispose (); Objbitmap.dispose (); } script>