zedgraph纵坐标与横坐标怎么绑定数据库
我想让显示出来的柱状图的高度随着数据库中的某一张表的一个字段的数据改变而改变同时也希望哪位高手帮帮忙能写一下代码是C#窗体程序不是ASP。net的使用zedgraph控件...
我想让显示出来的柱状图的高度随着数据库中的某一张表的一个字段的数据改变而改变
同时也希望 哪位高手帮帮忙能写一下代码
是C#窗体程序 不是ASP。net的
使用zedgraph控件 展开
同时也希望 哪位高手帮帮忙能写一下代码
是C#窗体程序 不是ASP。net的
使用zedgraph控件 展开
1个回答
展开全部
施行代码
{ DateTime dtstart = Convert.ToDateTime(this.ddlstartyear.SelectedValue.Trim() + "-" + this.ddlstartmonth.SelectedValue.Trim() + "-01");
DateTime dtend = Convert.ToDateTime(this.ddlendyear.SelectedValue.Trim() + "-" + this.ddlendmonth.SelectedValue.Trim() + "-01");
createimgprice(ref dtstart, dtend);}
页面显示是()年()月到()年()月的时间端
和一个显示图片的控件
去调用下面的方法
protected void createimgprice(ref DateTime starttime, DateTime endtime)
{
int arraycount = (endtime.Year - starttime.Year) * 12 + (endtime.Month - starttime.Month) + 1; //月总数
string[] montharray = new string[arraycount];
string[] month = new string[12];
float[] dprice = new float[arraycount];
int ii = 0;
int ibili = Convert.ToInt32(this.ddlbili.SelectedValue); //比例
while (starttime != endtime.AddMonths(1))
{
ProSellStatDal psd = new ProSellStatDal();
string search = " 1=1 ";
DataRow dr = psd.selProCGTJ(starttime.Year.ToString(), starttime.Month.ToString(), search);
montharray[ii] = starttime.Year.ToString().Substring(2, 2) + "年" + starttime.Month.ToString() + "月"; //月份
dprice[ii] = float.Parse(dr.ItemArray[0].ToString().Trim());
ii++;
starttime = starttime.AddMonths(1);
}
int imgcount = 0;
if (arraycount % 24 == 0)
{
imgcount = arraycount % 24;
}
else
{
imgcount = (arraycount % 24) + 1;
}
//画图初始化
Bitmap bMap = new Bitmap(ii * 30 + 140, 540);
Graphics gph = Graphics.FromImage(bMap);
gph.Clear(Color.White);
PointF cPt = new PointF(70, 420); //中心点
PointF[] xPt = new PointF[3] ;//Y轴三角形
PointF[] yPt = new PointF[3] ;//Y轴三角形
//画X轴
gph.DrawLine(Pens.Black, cPt.X, cPt.Y, cPt.X + arraycount * 30 + 15, cPt.Y);
gph.DrawPolygon(Pens.Black, xPt);
gph.FillPolygon(new SolidBrush(Color.Black), xPt);
//画Y轴
gph.DrawLine(Pens.Black, cPt.X, cPt.Y, cPt.X, cPt.X);
gph.DrawPolygon(Pens.Black, yPt);
gph.FillPolygon(new SolidBrush(Color.Black), yPt);
gph.DrawString("单位 ¥", new Font("宋体", 12), Brushes.Black, new PointF(0, 7));
//画Y轴刻度
for (int y = 0; y < 10; y++)
{
gph.DrawString(((y + 1) * ibili).ToString(), new Font("宋体", 11), Brushes.Black, new PointF(cPt.X - 60, cPt.Y - (y + 1) * 30 - 6));
gph.DrawLine(Pens.Black, cPt.X - 3, cPt.Y - (y + 1) * 30, cPt.X, cPt.Y - (y + 1) * 30);
}
for (int i = 0; i < montharray.Length; i++)
{
for (int y = 0; y < montharray[i].Length; y++)
{
//画X轴项目
gph.DrawString(montharray[i].Substring(y, 1), new Font("宋体", 11), Brushes.Black, new PointF(cPt.X + ((i + 1) * 30) - 5, cPt.Y + 5 + (y) * 20));
}
//画点
gph.DrawEllipse(Pens.Black, cPt.X + (i + 1) * 30 - 1.5F, cPt.Y - (30 * dprice[i] / ibili) - 1.5F, 3, 3);
gph.FillEllipse(new SolidBrush(Color.Black), cPt.X + (i + 1) * 30 - 1.5F, cPt.Y - (30 * dprice[i] / ibili) - 1.5F, 3, 3);
//画数值
gph.DrawString(dprice[i].ToString(), new Font("宋体", 11), Brushes.Black, new PointF(cPt.X + (i + 1) * 30, cPt.Y - (30 * dprice[i] / ibili) - 15));
//画折线
if (i > 0)
{
gph.DrawLine(Pens.Red, cPt.X + (i + 1) * 30, cPt.Y - (30 * dprice[i] / ibili), cPt.X + (i) * 30, cPt.Y - (30 * dprice[i - 1] / ibili));
}
}
//保存输出图片
bMap.Save(Server.MapPath("ProSellStatprice.gif"));
this.ImgPro.ImageUrl = "ProSellStatprice.gif";
}
产考一下。记住:sql要查某月的总数量,月的条件再用上面的循环就可以显示效果了;看不明白的话QQ(284345316)我,代码发给你
{ DateTime dtstart = Convert.ToDateTime(this.ddlstartyear.SelectedValue.Trim() + "-" + this.ddlstartmonth.SelectedValue.Trim() + "-01");
DateTime dtend = Convert.ToDateTime(this.ddlendyear.SelectedValue.Trim() + "-" + this.ddlendmonth.SelectedValue.Trim() + "-01");
createimgprice(ref dtstart, dtend);}
页面显示是()年()月到()年()月的时间端
和一个显示图片的控件
去调用下面的方法
protected void createimgprice(ref DateTime starttime, DateTime endtime)
{
int arraycount = (endtime.Year - starttime.Year) * 12 + (endtime.Month - starttime.Month) + 1; //月总数
string[] montharray = new string[arraycount];
string[] month = new string[12];
float[] dprice = new float[arraycount];
int ii = 0;
int ibili = Convert.ToInt32(this.ddlbili.SelectedValue); //比例
while (starttime != endtime.AddMonths(1))
{
ProSellStatDal psd = new ProSellStatDal();
string search = " 1=1 ";
DataRow dr = psd.selProCGTJ(starttime.Year.ToString(), starttime.Month.ToString(), search);
montharray[ii] = starttime.Year.ToString().Substring(2, 2) + "年" + starttime.Month.ToString() + "月"; //月份
dprice[ii] = float.Parse(dr.ItemArray[0].ToString().Trim());
ii++;
starttime = starttime.AddMonths(1);
}
int imgcount = 0;
if (arraycount % 24 == 0)
{
imgcount = arraycount % 24;
}
else
{
imgcount = (arraycount % 24) + 1;
}
//画图初始化
Bitmap bMap = new Bitmap(ii * 30 + 140, 540);
Graphics gph = Graphics.FromImage(bMap);
gph.Clear(Color.White);
PointF cPt = new PointF(70, 420); //中心点
PointF[] xPt = new PointF[3] ;//Y轴三角形
PointF[] yPt = new PointF[3] ;//Y轴三角形
//画X轴
gph.DrawLine(Pens.Black, cPt.X, cPt.Y, cPt.X + arraycount * 30 + 15, cPt.Y);
gph.DrawPolygon(Pens.Black, xPt);
gph.FillPolygon(new SolidBrush(Color.Black), xPt);
//画Y轴
gph.DrawLine(Pens.Black, cPt.X, cPt.Y, cPt.X, cPt.X);
gph.DrawPolygon(Pens.Black, yPt);
gph.FillPolygon(new SolidBrush(Color.Black), yPt);
gph.DrawString("单位 ¥", new Font("宋体", 12), Brushes.Black, new PointF(0, 7));
//画Y轴刻度
for (int y = 0; y < 10; y++)
{
gph.DrawString(((y + 1) * ibili).ToString(), new Font("宋体", 11), Brushes.Black, new PointF(cPt.X - 60, cPt.Y - (y + 1) * 30 - 6));
gph.DrawLine(Pens.Black, cPt.X - 3, cPt.Y - (y + 1) * 30, cPt.X, cPt.Y - (y + 1) * 30);
}
for (int i = 0; i < montharray.Length; i++)
{
for (int y = 0; y < montharray[i].Length; y++)
{
//画X轴项目
gph.DrawString(montharray[i].Substring(y, 1), new Font("宋体", 11), Brushes.Black, new PointF(cPt.X + ((i + 1) * 30) - 5, cPt.Y + 5 + (y) * 20));
}
//画点
gph.DrawEllipse(Pens.Black, cPt.X + (i + 1) * 30 - 1.5F, cPt.Y - (30 * dprice[i] / ibili) - 1.5F, 3, 3);
gph.FillEllipse(new SolidBrush(Color.Black), cPt.X + (i + 1) * 30 - 1.5F, cPt.Y - (30 * dprice[i] / ibili) - 1.5F, 3, 3);
//画数值
gph.DrawString(dprice[i].ToString(), new Font("宋体", 11), Brushes.Black, new PointF(cPt.X + (i + 1) * 30, cPt.Y - (30 * dprice[i] / ibili) - 15));
//画折线
if (i > 0)
{
gph.DrawLine(Pens.Red, cPt.X + (i + 1) * 30, cPt.Y - (30 * dprice[i] / ibili), cPt.X + (i) * 30, cPt.Y - (30 * dprice[i - 1] / ibili));
}
}
//保存输出图片
bMap.Save(Server.MapPath("ProSellStatprice.gif"));
this.ImgPro.ImageUrl = "ProSellStatprice.gif";
}
产考一下。记住:sql要查某月的总数量,月的条件再用上面的循环就可以显示效果了;看不明白的话QQ(284345316)我,代码发给你
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询