如何利用.net 绘制一个饼图?

yangjinhui 2010-04-07 05:04:00
我根据这个例子:
http://www.opent.cn/a/101/2367.shtml
绘制了柱形图,
请问如何绘制饼图?
...全文
439 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
hmc108 2010-04-25
  • 打赏
  • 举报
回复
免费的应用控件太多了。。。
zsuswy 2010-04-23
  • 打赏
  • 举报
回复
ms chart.net

使用极其方便,图形类型极其多样,本人极其推荐!
Purple_Sky2010 2010-04-23
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 foxer 的回复:]
如果是练习或者学习,俺就不掺呼了,如果是应用,就找一下MSChart.net,很漂亮的,还免费
[/Quote] 是的,只需要几个参数
mngzilin 2010-04-23
  • 打赏
  • 举报
回复
参考:

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Bitmap bmp = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(bmp);


GraphicsPath path1 = new GraphicsPath();
path1.AddArc(new Rectangle(0, 0, 100, 100), 0.0f, 90.0f);
path1.AddLine(new Point(50, 50), new Point(50, 100));
path1.AddLine(new Point(50, 50), new Point(100, 50));
g.FillPath(Brushes.Green, path1);

GraphicsPath path2 = new GraphicsPath();
path2.AddArc(new Rectangle(0, 0, 100, 100), 90.0f, 90.0f);
path2.AddLine(new Point(50, 50), new Point(0, 50));
path2.AddLine(new Point(50, 50), new Point(50, 100));
g.FillPath(Brushes.Black, path2);

GraphicsPath path3 = new GraphicsPath();
path3.AddArc(new Rectangle(0, 0, 100, 100), 180.0f, 90.0f);
path3.AddLine(new Point(50, 50), new Point(50, 0));
path3.AddLine(new Point(50, 50), new Point(0, 50));
g.FillPath(Brushes.Blue, path3);

GraphicsPath path4 = new GraphicsPath();
path4.AddArc(new Rectangle(0, 0, 100, 100), 270.0f, 90.0f);
path4.AddLine(new Point(50, 50), new Point(100, 50));
path4.AddLine(new Point(50, 50), new Point(50, 0));
g.FillPath(Brushes.Tomato, path4);

pictureBox1.Image = bmp;

}
zhang135956731 2010-04-23
  • 打赏
  • 举报
回复
用airport工具试试……专门的报表制作工具!
马老虎 2010-04-23
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 zsuswy 的回复:]

ms chart.net

使用极其方便,图形类型极其多样,本人极其推荐!
[/Quote]
如果使用vs2008(.net3.5)推荐使用这个!免费的
l13873666736 2010-04-23
  • 打赏
  • 举报
回复
ZEDGRAPH 好用,好看,不要錢
huangmin3956 2010-04-16
  • 打赏
  • 举报
回复
路过 学习点
理查德他哥 2010-04-15
  • 打赏
  • 举报
回复
我用的是webchart.dll控件,根据从数据库中读出的数据,可以生成饼图或其它的图形。
Foxer 2010-04-12
  • 打赏
  • 举报
回复
如果是练习或者学习,俺就不掺呼了,如果是应用,就找一下MSChart.net,很漂亮的,还免费
yzn800930 2010-04-10
  • 打赏
  • 举报
回复
mark
season1668 2010-04-09
  • 打赏
  • 举报
回复
学习中!!!!!!!!!!!!!!!!
season1668 2010-04-09
  • 打赏
  • 举报
回复
学习中!!!!!!!!!!!!!!!!
wuyq11 2010-04-09
  • 打赏
  • 举报
回复
zedgraph,ms chart,OWC都可
柱状图, 折线图, 扇形图
zhun_716 2010-04-09
  • 打赏
  • 举报
回复
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" Debug="true" %>
<!-- for .Net Framework 2.0 -->
<%@ Import Namespace="System.Drawing" %>
<script runat="server" language="c#">
void Page_Load(object sender, EventArgs e){
Bitmap image = new Bitmap(440,300);
Graphics g = Graphics.FromImage(image);

g.Clear(Color.White);

Rectangle outline = new Rectangle(10, 10, 420, 240);

g.DrawEllipse(new Pen(Color.Black, 4f), outline);

//create data
int[] b = new int[]{1565, 486, 5896, 1449};

float count = b[0] + b[1] + b[2] + b[3];
float[] c = new float[]{(b[0]/count), (b[1]/count), (b[2]/count), (b[3]/count)};
float[] a = new float[]{(360 * c[0]), (360 * c[1]), (360 * c[2]), (360 * c[3])};

//make area pie
g.FillPie(new SolidBrush(Color.Red), outline, 0f, a[0]);
g.FillPie(new SolidBrush(Color.Yellow), outline, a[0], a[1]);
g.FillPie(new SolidBrush(Color.Blue), outline, (a[0] + a[1]), a[2]);
g.FillPie(new SolidBrush(Color.Green), outline, (a[0] + a[1] + a[2]), a[3]);

//make color note start---
g.DrawRectangle(new Pen(Color.Black, 1f), new Rectangle(10, 260, 10, 10));
g.FillRectangle(new SolidBrush(Color.Red), 10, 260, 10, 10);
g.DrawString("1item:" + b[0].ToString(), new Font("Black", 10), new SolidBrush(Color.Black), 25, 260);

g.DrawRectangle(new Pen(Color.Black, 1f), new Rectangle(110, 260, 10, 10));
g.FillRectangle(new SolidBrush(Color.Yellow), 110, 260, 10, 10);
g.DrawString("2item:" + b[1].ToString(), new Font("Black", 10), new SolidBrush(Color.Black), 125, 260);

g.DrawRectangle(new Pen(Color.Black, 1f), new Rectangle(210, 260, 10, 10));
g.FillRectangle(new SolidBrush(Color.Blue), 210, 260, 10, 10);
g.DrawString("3item:" + b[2].ToString(), new Font("Black", 10), new SolidBrush(Color.Black), 225, 260);

g.DrawRectangle(new Pen(Color.Black, 1f), new Rectangle(310, 260, 10, 10));
g.FillRectangle(new SolidBrush(Color.Green), 310, 260, 10, 10);
g.DrawString("4item:s" + b[3].ToString(), new Font("Black", 10), new SolidBrush(Color.Black), 325, 260);
//make color note end---

//mark string
g.DrawString(".Net Drawing", new Font("Arial Black", 20), new SolidBrush(Color.White), 100, 80);

image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
//Response.Write(a[0]+"/"+a[1]+"/"+a[2]+"/"+a[3]);
//Response.Write((b[0]/(float)count*100));
Response.ContentType="Image/Gif";
}
</script>
disciple_wr 2010-04-08
  • 打赏
  • 举报
回复
chartdir_net

13,347

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET技术前瞻
社区管理员
  • .NET技术前瞻社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧