Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of generating pie chart on ASP.Net page

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report