社区
图表区
帖子详情
动态柱状图
www5net
2014-02-21 05:39:07
语言Csharp 软件 visual studio2010 数据库 sql server 2008 gid+绘图 完整代码 求教怎么做
...全文
207
5
打赏
收藏
动态柱状图
语言Csharp 软件 visual studio2010 数据库 sql server 2008 gid+绘图 完整代码 求教怎么做
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
www5net
2014-02-26
打赏
举报
回复
protected void Page_Load(object sender, EventArgs e) { this.CreateImage(); } private int Total() { SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSql1"]); Con.Open(); string cmdtxt1 = "select CONVERT(varchar(100), t1.FendDate, 23) as 结束日期,t2.Fqty as 额定产能,t2.Fuseqty as 已用产能 from t_planed_BOS t1,t_planedentry_BOS t2 where t1.FID =t2.FID and t1.FBillNo like '旬%' and t2.Fnumber='JG' and " + DropDownList1.SelectedValue.ToString().Trim() + " like '%" + TextBox1.Text.ToString().Trim() + "%'"; SqlDataAdapter dap = new SqlDataAdapter(cmdtxt1, Con); DataSet ds = new DataSet(); dap.Fill(ds); int P_Int_total = ds.Tables[0].Rows.Count;//访问人数统计 return P_Int_total; } private void CreateImage() { int height = 1000, width = 1000; Bitmap image = new Bitmap(width, height); //创建Graphics类对象 Graphics g = Graphics.FromImage(image); try { //清空图片背景色 g.Clear(Color.White); Font font = new Font("Arial", 9, FontStyle.Regular); Font font1 = new Font("宋体", 20, FontStyle.Bold); LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.BlueViolet, 1.2f, true); g.FillRectangle(Brushes.WhiteSmoke, 500, 500, width, height); // Brush brush1 = new SolidBrush(Color.Blue); g.DrawString("2014年各月份网站流量统计", font1, brush, new PointF(130, 30)); //画图片的边框线 g.DrawRectangle(new Pen(Color.Blue), 0, 0, image.Width - 1, image.Height - 1); Pen mypen = new Pen(brush, 1); //绘制线条 //绘制横向线条 int x = 100; for (int i = 0; i < 11; i++) { g.DrawLine(mypen, x, 80, x, 340); x = x + 40; } Pen mypen1 = new Pen(Color.Blue, 2); g.DrawLine(mypen1, x - 480, 80, x - 480, 340); //绘制纵向线条 int y = 106; for (int i = 0; i < 9; i++) { g.DrawLine(mypen, 60, y, 540, y); y = y + 26; } g.DrawLine(mypen1, 60, y, 540, y); //x轴 String[] n = {" 一月", " 二月", " 三月", " 四月", " 五月", " 六月", " 七月", " 八月", " 九月", " 十月", "十一月", "十二月","dddd"}; x = 62; for (int i = 0; i < 13; i++) { g.DrawString(n[i].ToString(), font, Brushes.Black, x, 348); //设置文字内容及输出位置 x = x + 40; } //y轴 String[] m = {"100%", " 90%", " 80%", " 70%", " 60%", " 50%", " 40%", " 30%", " 20%", " 10%", " 0%"}; y = 85; for (int i = 0; i < 11; i++) { g.DrawString(m[i].ToString(), font, Brushes.Black, 25, y); //设置文字内容及输出位置 y = y + 26; } int[] Count = new int[12]; string cmdtxt2 = ""; SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSql1"]); Con.Open(); SqlDataAdapter da; DataSet ds = new DataSet(); for (int i = 0; i < 12; i++) { cmdtxt2 = "select COUNT(10) AS count, Month( FendDate) AS month from t_planed_BOS where Year(FendDate)=2014 and Month(FendDate)=" + (i + 1) + "Group By Month(FendDate)"; da = new SqlDataAdapter(cmdtxt2, Con); da.Fill(ds, i.ToString()); if (ds.Tables[i].Rows.Count == 0) { Count[i] = 0; } else { Count[i] = Convert.ToInt32(ds.Tables[i].Rows[0][0].ToString()) * 100 / Total(); } } //显示柱状效果 x = 70; for (int i = 0; i < 12; i++) { SolidBrush mybrush = new SolidBrush(Color.Red); g.FillRectangle(mybrush, x, 340 - Count[i] * 26/5 , 20, Count[i] * 26/5); x = x + 40; } System.IO.MemoryStream ms = new System.IO.MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Response.ClearContent(); Response.ContentType = "image/Jpeg"; Response.BinaryWrite(ms.ToArray()); } finally { g.Dispose(); image.Dispose(); }
www5net
2014-02-21
打赏
举报
回复
谁有现成代码 求发求指导
小驴来这里学习
2014-02-21
打赏
举报
回复
引用 2 楼 u013722684 的回复:
百度了太乱没时间研究
呵呵
www5net
2014-02-21
打赏
举报
回复
百度了太乱没时间研究
小贤820
2014-02-21
打赏
举报
回复
度娘哪里绝对有答案!!!
python实现
动态
柱状图
本文介绍如何使用PyEcharts库绘制基础
柱状图
、时间线
柱状图
及GDP
动态
柱状图
,包括反转坐标轴、设置标签位置、自动播放等功能。
Qt练手小项目之绘制
动态
柱状图
本文介绍了使用Qt 4.8.6和VS2008实现
动态
柱状图
的方法。该
柱状图
可根据数据实时增减,支持修改刻度范围、颜色等。详细说明了背景、刻度线、刻度值、
柱状图
及背景的绘制过程,并给出了主要部分的源码,还提供了整个工程的下载链接。
Python
动态
柱状图
的绘制
本文介绍了如何使用Python绘制
动态
柱状图
,包括基础
柱状图
、基础时间线
柱状图
和GDP
动态
柱状图
。在绘制GDP
动态
柱状图
时,重点讲解了如何利用列表sort方法和lambda函数进行数据排序,并提供了完整代码示例。
动态
排序
柱状图
本文详细介绍了如何使用Apache ECharts 5创建
动态
排序
柱状图
,包括开启Y轴
动态
排序、设置动画效果和实时更新数据的方法。通过调整yAxis的相关属性和series.label设置,可以实现数据排名变化的可视化,并提供了完整示例代码。
QML -
动态
柱状图
该博客介绍了QML实现
动态
柱状图
的相关内容。并非真的频谱
柱状图
,而是用随机数实现数组数据。还提及了文件结构,包含BarGraphArea.qml和BarItem.qml文件内容,同时给出了代码存放地址。
图表区
4,818
社区成员
14,134
社区内容
发帖
与我相关
我的任务
图表区
.NET技术 图表区
复制链接
扫一扫
分享
社区描述
.NET技术 图表区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章