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
查看全文
相关阅读:
GJM : Unity的profiler性能分析【转载】
GJM :Unity UI 之 UGUI 开发
GJM:笔记记录
GJM : UGUI 缩放循环拖动展示卡牌效果
GJM :HTC Vive VRTK.Package 踩坑之路(一)
GJM :Mono 介绍
GJM :Unity3D 介绍
GJM : C# 介绍
GJM : 通用类型系统(Common Type System CTS)
GJM :SQL Server中常用的SQL语句
原文地址:https://www.cnblogs.com/coolbug/p/42850.html
最新文章
增,删,改 的配置文件
关于instanface的问题
JavaScript中常用的数据输出方式解析
移动端水平导航滚动条
函数节流和函数防抖
jQuery中attr()与prop()的区别
vue-cli
网页布局方式
JS中call()、apply()、bind()的用法
js中模拟移动端长按效果
热门文章
Node.js使用npm安装模块太慢,解决办法
原生js实现懒加载并节流
图片预加载
GJM : Unity3D HIAR 目录导航
GJM : 常用网站收集 【不断更新中... ... ... 】
GJM:移动App入侵与逆向破解技术-iOS篇 【转载】
GJM:Unity 脚本生命周期流程图
GJM : 使用Html5下WebSocket搭建简易聊天室 【转载】
GJM : VScode 整理 【转载】
GJM : 发布APK 到 Google Play(Android Market)官方市场
Copyright © 2011-2022 走看看