Use C # and GDI + to draw a bar chart (Data painting can be exported from the database)
Return at night and draw out the variable name in a hurry. The figure is as follows:
Public void Bind ()
{
// Create a canvas
Bitmap bm = new Bitmap (240,210 );
// Draw a chart on the newly created canvas
Graphics bp = Graphics. FromImage (bm );
// Set the background color of bp to Beige.
Bp. Clear (Color. Beige );
// Create a data source, which is an array
Int [] a1 = {20, 40, 60, 80, 100,120,140,160 };
Int [] a2 = {40,60, 80,100,120,140,160,180 };
Bp. DrawRectangle (Pens. Black, 1, 1, 230,205 );
// Draw a bar chart cyclically
For (int I = 0; I <a1.Length; I ++)
{
// Fill the graph (coloring, starting point X, starting point Y, width, and height)
Bp. FillRectangle (new SolidBrush (Color. Blue), (I * 30) + 5,-a1 [I], 5, a1 [I] + 5 );
// Fill the border (coloring, starting point X, starting point Y, width, and height)
Bp. DrawRectangle (Pens. Black, (I * 30) + 5,200-a1 [I], 5, a1 [I] + 5 );
}
// Bar chart 2
For (int I = 0; I <a2.Length; I ++)
{
Bp. FillRectangle (new SolidBrush (Color. Red), (I * 30) +-a2 [I], 5, a2 [I] + 5 );
Bp. DrawRectangle (Pens. Black, (I * 30) +-a2 [I], 5, a2 [I] + 5 );
}
// Output to IE in gif format
Bm. Save (Response. OutputStream, ImageFormat. Gif );
}