ightYellow), 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>