How to generate pie and bar chart in asp.net
This article introduces the relevant knowledge of "how to generate pie and bar charts in asp.net". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Common methods for generating graphics:
The copy code is as follows:
Using System
Using System.Collections.Generic
Using System.Text
/ /
/ / using System.Data
/ / using System.Web.UI.WebControls
/ /
Using System.Drawing
Using System.Drawing.Imaging
Namespace Tools
{
Public static class OWCImageHelp
{
/ / /
/ / dynamically generate histogram and pie chart
/ / /
/ / Fields to be displayed in row coordinates
/ / the number to be displayed in the ordinate
/ / title
Public static void GetZBImage (string [] arrValueNames, int [] arrValues, string title)
{
Bitmap objBitMap = new Bitmap (650,300)
Graphics objGraphics
ObjGraphics = Graphics.FromImage (objBitMap)
ObjGraphics.Clear (Color.White)
/ / int [] arrValues = {40000, 32000, 24000, 30000, 36000, 28000}
/ / string [] arrValueNames = new string [] {"first", "second", "third", "fourth", "fifth", "sixth"}
ObjGraphics.DrawString (title, new System.Drawing.Font (Song style, 16), Brushes.Blue, new PointF (5,5))
PointF symbolLeg = new PointF (335,20)
PointF descLeg = new PointF (360,16)
/ / draw the figure in the description section
For (int I = 0; I < arrValueNames.Length; iTunes +)
{
ObjGraphics.FillRectangle (new SolidBrush (GetColor (I)), symbolLeg.X, symbolLeg.Y, 20, 10)
ObjGraphics.DrawRectangle (Pens.Black, symbolLeg.X, symbolLeg.Y, 20, 10)
ObjGraphics.DrawString (arrValueNams [I] .ToString (), new System.Drawing.Font ("Verdana", 10), Brushes.Black, descLeg)
SymbolLeg.Y + = 15
DescLeg.Y + = 15
}
Float TotalValues = 0
For (int I = 0; I