zedgraph折线图
各位好!我现在遇到的问题大意为:在一幅折线图中,假如已有3条折线,我如何实现去掉其中特定的一条折线。之前的方法是:先完全清除再绑定,这样有刷新抖动。查了网上:Toremo...
各位好!
我现在遇到的问题大意为:在一幅折线图中,假如已有3条折线,我如何实现去掉其中特定的一条折线。
之前的方法是:先完全清除再绑定,这样有刷新抖动。
查了网上:
To remove just one PieItem object:
Dim zgc As ZedGraph.ZedGraphControl = Me.ZedGraphControl1
Dim zgPane As ZedGraph.GraphPane = zgc.GraphPane
Dim zgPieItem As ZedGraph.PieItem = zgPane.CurveList("PieItemLabel")
zgPane.CurveList.Remove(zgPieItem)
但这没看懂如何使用!恳请,知道的人指教!谢谢 展开
我现在遇到的问题大意为:在一幅折线图中,假如已有3条折线,我如何实现去掉其中特定的一条折线。
之前的方法是:先完全清除再绑定,这样有刷新抖动。
查了网上:
To remove just one PieItem object:
Dim zgc As ZedGraph.ZedGraphControl = Me.ZedGraphControl1
Dim zgPane As ZedGraph.GraphPane = zgc.GraphPane
Dim zgPieItem As ZedGraph.PieItem = zgPane.CurveList("PieItemLabel")
zgPane.CurveList.Remove(zgPieItem)
但这没看懂如何使用!恳请,知道的人指教!谢谢 展开
3个回答
2011-07-06
展开全部
施行代码
{ 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)我,代码发给你
另外,站长团上有产品团购,便宜有保证
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
施行代码
{ 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)我,代码发给你
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
To remove just one PieItem object:
Dim zgc As ZedGraph.ZedGraphControl = Me.ZedGraphControl1
Dim zgPane As ZedGraph.GraphPane = zgc.GraphPane
Dim zgc As ZedGraph.ZedGraphControl = Me.ZedGraphControl1
Dim zgPane As ZedGraph.GraphPane = zgc.GraphPane
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询