Get the App
SLTechnology News&Howtos  ›  Development  › 

The method of generating pie chart on ASP.Net page

Shulou Source: shulou.com Published: 2022-06-03 19:55:35 10月22日 Update

This article mainly explains "the method of generating pie chart on ASP.Net page". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the method of generating pie chart on ASP.Net page".

1. Generate a normal pie chart:

The copy code is as follows:

Using System

Using System.Collections.Generic

Using System.Drawing

Using System.Drawing.Imaging

Using System.Linq

Using System.Web

Using System.Web.UI

Using System.Web.UI.WebControls

Public partial class Drawing: System.Web.UI.Page

{

Protected void Page_Load (object sender, EventArgs e)

{

Int [] data = {100200300460}

Color [] colors= {Color.Green,Color.Blue,Color.Yellow,Color.Tomato}

Bitmap bm = new Bitmap (400400)

Graphics g = Graphics.FromImage (bm)

G.Clear (Color.White)

G.DrawString ("pie chart test", new Font ("Song style", 16), Brushes.Red,new PointF (5jue 5))

Float totalValue = 0

Foreach (int i in data)

{

TotalValue + = I

}

Float sweepAngle = 0

Float startAngle = 0

Int index=0

Float x = 50f

Float y = 50f

Float width = 200f

Foreach (int i in data)

{

SweepAngle=i/totalValue*360

G.FillPie (new SolidBrush (colors [index + +]), XRecience, WidthJournal, widthReceiver, start Angle, sweepAngle)

/ / g.DrawPie (Pens.Black,x,y,width,width,startAngle,sweepAngle); / / add edge code

StartAngle + = sweepAngle

}

Bm.Save (Response.OutputStream,ImageFormat.Jpeg)

G.Dispose ()

}

}

The running effect is shown in the following figure:

two。 If the pie chart needs to be edged, uncomment the annotated part of the code above, as shown in the following code:

The copy code is as follows:

G.DrawPie (Pens.Black,x,y,width,width,startAngle,sweepAngle)

The running result is as follows:

At this point, I believe that everyone on the "ASP.Net page to generate pie chart method" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Code methods generation pages content comments sidelines learning running practical ordinary deeper interest Arial practicality practicality simple operation effect more friends Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Information MariaDB Xiaomi Shulou Tech Info