晚上归来,匆忙画出下图,变量命名简简单单取的.图如下:
![aaa.gif](https://i-blog.csdnimg.cn/blog_migrate/b081c3051668dae509b3dcd78d6d0a74.gif)
public
void
Bind()
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
//创建一个画布
Bitmap bm=new Bitmap(240,210);
//在新建的画布上画一个图
Graphics bp=Graphics.FromImage(bm);
//设置bp的背景色为Beige
bp.Clear(Color.Beige);
//创建数据源,在此为一个数组
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
int [] a1=
{20,40,60,80,100,120,140,160};
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
int [] a2=
{40,60,80,100,120,140,160,180};
bp.DrawRectangle(Pens.Black,1,1,230,205);
//通过循环画出柱状图
for(int i=0;i<a1.Length;i++)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//填充图(着色,起点X,起点Y,宽,高)
bp.FillRectangle(new SolidBrush(Color.Blue),(i*30)+5,200-a1[i],5,a1[i]+5);
//填充边框(着色,起点X,起点Y,宽,高)
bp.DrawRectangle(Pens.Black,(i*30)+5,200-a1[i],5,a1[i]+5);
}
//柱图2
for(int i=0;i<a2.Length;i++)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
bp.FillRectangle(new SolidBrush(Color.Red),(i*30)+10,200-a2[i],5,a2[i]+5);
bp.DrawRectangle(Pens.Black,(i*30)+10,200-a2[i],5,a2[i]+5);
}
//以gif格式输出到IE上
bm.Save(Response.OutputStream,ImageFormat.Gif);
}