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

How to generate pie and bar chart in asp.net

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

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

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