C# Chart中数据更新,该怎么解决
C# Chart中数据更新
刚接触这个控件,目前我在设计时手动添加好了DataPoint,可以直接看到效果
在程序中用Timer控件循环更新里面的值,但是控件没有变化,还需要加上什么代码?
------解决方案--------------------
Timer的Interval、Enabled属性怎么设置的,Tick事件有没有关联给Timer_Tick
------解决方案--------------------
如果直接调用 ShowChart6()正常,那放在timer里也应该正常,你timer的Interval设置为多少
------解决方案--------------------
这个放在load里吧,这样试试
this.timer.Interval = 20000;
this.timer.Enabled = true;
if (updateWinform)
{
this.ShowChart6();
updateWinform = false;
this.timer.Enabled = false;
}
刚接触这个控件,目前我在设计时手动添加好了DataPoint,可以直接看到效果
在程序中用Timer控件循环更新里面的值,但是控件没有变化,还需要加上什么代码?
private void Timer_Tick(object sender, EventArgs e)
{
this.ShowChart6();
}
private void ShowChart6()
{
for (int groupIndex = 0; groupIndex < 12; groupIndex++)
{
this.chart6.Series[0].Points[groupIndex].AxisLabel = this.CountList.Groups[groupIndex].Header;
this.chart6.Series[0].Points[groupIndex].YValues[0] = Double.Parse(this.CountList.Groups[groupIndex].Items[0].SubItems[1].Text);
this.chart6.Series[1].Points[groupIndex].YValues[0] = Double.Parse(this.CountList.Groups[groupIndex].Items[1].SubItems[1].Text);
this.chart6.Series[2].Points[groupIndex].YValues[0] = Double.Parse(this.CountList.Groups[groupIndex].Items[2].SubItems[1].Text);
}
}
------解决方案--------------------
Timer的Interval、Enabled属性怎么设置的,Tick事件有没有关联给Timer_Tick
------解决方案--------------------
如果直接调用 ShowChart6()正常,那放在timer里也应该正常,你timer的Interval设置为多少
------解决方案--------------------
这个放在load里吧,这样试试
this.timer.Interval = 20000;
this.timer.Enabled = true;
if (updateWinform)
{
this.ShowChart6();
updateWinform = false;
this.timer.Enabled = false;
}