用asp.net画饼图
2007-12-15 09:30:51 来源:WEB开发网核心提示://Bitmap objbitmap=new Bitmap(230,500);//创建一个bitmap实例Graphics objgraphics=Graphics.FromImage(objbitmap);objgraphics.FillRectangle(new SolidBrush(Color.White), 0
//Bitmap objbitmap=new Bitmap(230,500);//创建一个bitmap实例
Graphics objgraphics=Graphics.FromImage(objbitmap);
objgraphics.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);//画一个白色背景
objgraphics.FillRectangle(new SolidBrush(Color.LightYellow), pierect);//画一个亮黄色背景
//以下为画饼图(有几行row画几个)
float currentdegree=0.0f;
for (iloop = 0; iloop < ds.Tables[0].Rows.Count; iloop++)
{
objgraphics.FillPie((SolidBrush) colors[iloop], pierect, currentdegree,
Convert.ToSingle(ds.Tables[0].Rows[iloop]["point"]) / total * 360);
currentdegree += Convert.ToSingle(ds.Tables[0].Rows[iloop]["point"]) / total * 360;
}
//---以下为生成主标题
SolidBrush blackbrush=new SolidBrush(Color.Black);
string title="本次《程序员大本营》推出了配套的专刊,您对专刊满意吗?";
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
objgraphics.DrawString(title, fonttitle, blackbrush,
new Rectangle(0, 0, width, titleheight), stringFormat);
//列出各字段与得票数
objgraphics.DrawRectangle(new Pen(Color.Black, 2), 0, height - legendheight, width, legendheight);
for (iloop = 0; iloop < ds.Tables[0].Rows.Count; iloop++)
{
objgraphics.FillRectangle((SolidBrush) colors[iloop], 5, height - legendheight + fontlegend.Height * iloop + 5, 10, 10);
objgraphics.DrawString(((String) ds.Tables[0].Rows[iloop]["title"]) + " - " + Convert.ToString(ds.Tables[0].Rows[iloop]["point"]), fontlegend, blackbrush,
20, height - legendheight + fontlegend.Height * iloop + 1);
}
//
objgraphics.DrawString("总票数是:"+Convert.ToString(total),fontlegend,blackbrush, 5, height - fontlegend.Height );
//图像总的高度-一行字体的高度,即是最底行的一行字体高度(height - fontlegend.Height )
Response.ContentType="image/jpeg";
objbitmap.Save(Response.OutputStream,ImageFormat.Jpeg);
//objbitmap.Save("myyyyyyyyyyy.jpg", ImageFormat.Jpeg);//输出到文件
objgraphics.Dispose();
objbitmap.Dispose();
}
</script>
- ››ASP.NET及JS中的cookie基本用法
- ››ASP.NET获取MS SQL Server安装实例
- ››asp.net实现调用百度pai 在线翻译英文转中文
- ››ASP.NET页面选项进行提示判断
- ››Asp.net定时执行程序
- ››ASP.NET中利用DataList实现图片无缝滚动
- ››ASP.NET验证控件RequiredFieldValidator
- ››ASP.NET中使用System.Net.Mail发邮件
- ››ASP.NET中获取用户控件中控件的ID
- ››ASP.NET中FileBytes写成文件并存档
- ››asp获取毫秒数
- ››asp.net报“INSERT INTO 语句的语法错误解决
更多精彩
赞助商链接