chart 的一点小问题

祥子爱游戏 2013-12-20 09:50:38
LegendCollection”中已存在名为“lengend1”的图表元素
...全文
269 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
祥子爱游戏 2013-12-20
  • 打赏
  • 举报
回复
看foreach,数据是gridview中的数据,我改变了gridview中的数据就坏了
祥子爱游戏 2013-12-20
  • 打赏
  • 举报
回复
public void getchart() { //Chart1.ChartAreas.Clear();//清空 //string name = null; Chart1.Width = 1000; Chart1.Height = 400; Chart1.ChartAreas[0].AxisY.Minimum = 0; Chart1.ChartAreas[0].AxisY.Maximum = 0.3; Chart1.ChartAreas[0].AxisY.Interval = 0.02; //Chart1.ChartAreas[0].AxisX.Interval = 0.3; //Chart1.RenderType = RenderType.ImageTag; Chart1.ChartAreas[0].AxisY.Title = "百分率"; Chart1.ChartAreas[0].AxisX.Title = "系部名称"; foreach (GridViewRow gvr in GridView1.Rows) { Chart1.Series["旷课"].Points.AddXY(gvr.Cells[0].Text, gvr.Cells[3].Text.ToString()); Chart1.Series["迟到"].Points.AddXY(gvr.Cells[0].Text, gvr.Cells[5].Text.ToString()); Chart1.Series["早退"].Points.AddXY(gvr.Cells[0].Text, gvr.Cells[7].Text.ToString()); Chart1.Series["请假"].Points.AddXY(gvr.Cells[0].Text, gvr.Cells[9].Text.ToString()); Chart1.Series["总缺勤"].Points.AddXY(gvr.Cells[0].Text, gvr.Cells[11].Text.ToString()); } Chart1.Series["旷课"].Color = System.Drawing.Color.Red; Chart1.Series["迟到"].Color = System.Drawing.Color.Blue; Chart1.Series["早退"].Color = System.Drawing.Color.Green; Chart1.Series["请假"].Color = System.Drawing.Color.Orange; Chart1.Series["总缺勤"].Color=System.Drawing.Color.Black; Chart1.Series["旷课"]["PointWidth"] = "0.2"; Chart1.Series["迟到"]["PointWidth"] = "0.2"; Chart1.Series["请假"]["PointWidth"] = "0.2"; Chart1.Series["早退"]["PointWidth"] = "0.2"; Chart1.Series["总缺勤"]["PointWidth"] = "0.2"; Chart1.Legends.Add("lengend1"); //Chart1.ChartAreas["Series1"].Area3DStyle.Enable3D = true;3d样式 }
祥子爱游戏 2013-12-20
  • 打赏
  • 举报
回复
要我贴的代码吗?我是用一个area重复添加好几个gridview的数据
熙风 2013-12-20
  • 打赏
  • 举报
回复
明显是重复添加了,你看下你的代码
蝶恋花雨 2013-12-20
  • 打赏
  • 举报
回复
改成下面的试试 Chart1.Legends.Add(new Legend("Legend1")); http://msdn.microsoft.com/en-us/library/dd456711%28VS.100%29.aspx
蝶恋花雨 2013-12-20
  • 打赏
  • 举报
回复
LegendCollection 检查有没有两个lengend1 。没有的话是不是在Add之前清除下。
祥子爱游戏 2013-12-20
  • 打赏
  • 举报
回复
大神们。还没起床吗

4,816

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧