zoukankan
html css js c++ java
柱状图改进版
public
void
BindBitmap()
{
//
创建一个画布
Bitmap bm
=
new
Bitmap(
350
,
355
);
//
在新建的画布上画一个图
Graphics bp
=
Graphics.FromImage(bm);
//
设置bp的背景色为White
bp.Clear(Color.White);
//
创建数据源,在此为一个数组,这里可以从数据集(DataSet)中获取数据.
int
[] a1
=
{
20
,
40
,
60
,
80
,
100
,
120
,
140
,
160
}
;
int
[] a2
=
{
40
,
60
,
80
,
100
,
120
,
140
,
160
,
180
}
;
//
画一个矩形,将柱形图圈起来
bp.FillRectangle(
new
SolidBrush(Color.Beige),
1
,
1
,
255
,
205
);
bp.DrawRectangle(Pens.Black,
1
,
1
,
255
,
205
);
//
定义一种样式
StringFormat fontStyle
=
new
System.Drawing.StringFormat(StringFormatFlags.DisplayFormatControl);
//
通过循环画出柱状图
//
柱图1 --Blue
for
(
int
i
=
0
;i
<
a1.Length;i
++
)
{
//
填充图(着色,起点X,起点Y,宽,高)
bp.FillRectangle(
new
SolidBrush(Color.Blue),(i
*
30
)
+
25
,
200
-
a1[i],
5
,a1[i]
+
5
);
//
填充边框(着色,起点X,起点Y,宽,高)
bp.DrawRectangle(Pens.Black,(i
*
30
)
+
25
,
200
-
a1[i],
5
,a1[i]
+
5
);
//
输出月份
bp.DrawString((i
+
1
).ToString()
+
"
月
"
,
new
Font(
"
宋体
"
,
10
), Brushes.Black ,(i
*
30
)
+
18
,
210
,fontStyle);
}
//
柱图2--Red
for
(
int
i
=
0
;i
<
a2.Length;i
++
)
{
bp.FillRectangle(
new
SolidBrush(Color.Red),(i
*
30
)
+
30
,
200
-
a2[i],
5
,a2[i]
+
5
);
bp.DrawRectangle(Pens.Black,(i
*
30
)
+
30
,
200
-
a2[i],
5
,a2[i]
+
5
);
}
//
画两个例子图
//
旁边的"产品A"
bp.FillRectangle(
new
SolidBrush(Color.Blue),
280
,
10
,
20
,
10
);
bp.DrawRectangle(Pens.Black,
280
,
10
,
20
,
10
);
bp.DrawString(
"
产品A
"
,
new
Font(
"
宋体
"
,
10
), Brushes.Black ,
305
,
10
,fontStyle);
//
旁边的"产品B"
bp.FillRectangle(
new
SolidBrush(Color.Red),
280
,
30
,
20
,
10
);
bp.DrawRectangle(Pens.Black,
280
,
30
,
20
,
10
);
bp.DrawString(
"
产品B
"
,
new
Font(
"
宋体
"
,
10
), Brushes.Black ,
305
,
30
,fontStyle);
bp.DrawString(
"
臭虫公司销虫量
"
,
new
Font(
"
宋体
"
,
12
), Brushes.Black ,
45
,
230
,fontStyle);
//
以gif图片格式把图输出到IE上
bm.Save(Response.OutputStream,ImageFormat.Gif);
}
阿里云优惠券领取地址:https://partner.aliyun.com/shop/35783975 ,需要更多优惠请联系QQ和微信:891115,热线:400-968-4968
查看全文
相关阅读:
imagemagick-图片
selenium-嘿
centos命令行连接无线网络
centos7安装桌面合盖不休眠
mysql执行命令:ERROR 1820 (HY000): You must reset your password
编码规范 C++
Docker使用总结
JAVA使用总结
VS IDE 相关
编程网站总结
原文地址:https://www.cnblogs.com/coolbug/p/42850.html
最新文章
百度地图api标注求职信息
ubuntu1604-netease music
修改数据库的时区
harbor镜像仓库的权限控制-未整理
python虚拟环境
格式化U盘
集群资源管理
service-k8s
pod-k8s
makefile构建docker镜像
热门文章
故障排查-k8s
Deployment-k8s
daemonset-k8s
jenkins 迁移
ansible
systemd-service
ubuntu命令-http
激活windows-u盘制作多系统
网x易x云-xxxx
解析网站robots.txt是否可以爬取
Copyright © 2011-2022 走看看