晚上归来,匆忙画出下图,变量命名简简单单取的.图如下:
![](/images/cnblogs_com/coolbug/aaa.gif)
public void Bind()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
//创建一个画布
Bitmap bm=new Bitmap(240,210);
//在新建的画布上画一个图
Graphics bp=Graphics.FromImage(bm);
//设置bp的背景色为Beige
bp.Clear(Color.Beige);
//创建数据源,在此为一个数组
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
int [] a1=
{20,40,60,80,100,120,140,160};
![](/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++)
![](/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++)
![](/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);
}
![](/Images/OutliningIndicators/None.gif)
阿里云优惠券领取地址:https://partner.aliyun.com/shop/35783975 ,需要更多优惠请联系QQ和微信:891115,热线:400-968-4968
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步