MSChart 滚动条实现 +绘图
我的 Windows 窗体中有一个 MSCHart 控件,用 C# 编码。基本上我有一组数据来填充图表。我需要对这些进行以下操作:
1)在 10 秒帧内阅读图表 2) 在每 10 秒帧中,我需要每秒从数组中绘制 170 个数据项。并且这种情况会一直持续到最后。
抱歉,我知道这听起来有点冗长,但我已尽力实现这一点,但我得到的结果只是失败。
如果有人可以帮助我阐明这一点,我将不胜感激。
这是我到目前为止所做的一个片段
#region SetupChart()
public bool SetupChart()
{
try
{
//Here is where I create the chart scale to show frames of 10 secs
this.view.chart.ChartAreas[0].AxisX.ScaleView.Size = 10;
return true;
}
catch { return false; }
}
#endregion
#region Draw()
public bool Draw()
{
try
{
view.Data = this.dllCall.GetData(1);
int startSecond = 0;
foreach (Int16 item in view.Data)
{
//Here is where I read each element from my array, unsure how to plot 170 per second :S
this.view.chart.Series["MySeries"].Points.AddXY(startSecond, item);
startSecond++;
}
return true;
}
catch (Exception ex)
{
this.ErrorMessage = ex.Message;
return false;
}
}
,正如您从上面的代码中看到的,我已经让图表在开始时以 10 秒的帧显示,但在设计视图中,滚动条没有出现在我的图表下方,我无法弄清楚如何实现滚动条以显示下一个 10 秒帧,目前当我单击滚动时,它以 1 秒为步长,所以在开始时为 0 - 10,单击滚动,为 1 - 11。我 我想要它,所以当我单击滚动时,它会从 0-10 变为 10 - 20。
我提到的其他问题是每秒显示 170 个数据样本,
请有人可以在我自己的代码之上向我展示示例代码,以向我展示这是如何实现的实施我将不胜感激,提前非常感谢!
I have an MSCHart control in my windows Form, coding in C#. Basically I have an array of Data to populate the chart. I was needing to do the following with these:
1) Read the chart in 10 second frames
2) In each 10 second frame I need to plot 170 data items per second from my array. and this would continue to the end.
Sorry I know this sounds a bit lengthy but I have tried my best to implement this and the result I get back is just fail.
If anyone could please help shed some light on this for me I would greatly appreciate it.
here is a snipplet of what I done so far
#region SetupChart()
public bool SetupChart()
{
try
{
//Here is where I create the chart scale to show frames of 10 secs
this.view.chart.ChartAreas[0].AxisX.ScaleView.Size = 10;
return true;
}
catch { return false; }
}
#endregion
#region Draw()
public bool Draw()
{
try
{
view.Data = this.dllCall.GetData(1);
int startSecond = 0;
foreach (Int16 item in view.Data)
{
//Here is where I read each element from my array, unsure how to plot 170 per second :S
this.view.chart.Series["MySeries"].Points.AddXY(startSecond, item);
startSecond++;
}
return true;
}
catch (Exception ex)
{
this.ErrorMessage = ex.Message;
return false;
}
}
As you can see from my above code, I have got the chart to show in a 10 sec frame at the beginning, but in design view the scroll bar does not appear below my chart, I cant figure out how to implement the scroll bar to show the next 10 sec frame, currently when I click to scroll it does it in steps of 1 second, so at the beginning its 0 - 10, click scroll, its 1 - 11. I wanted it so when I click the scroll it would go from 0-10 to 10 - 20.
Other problem I mentioned is showing 170 data samples per second,
Please if someone could show me example code ontop of my own to show me how this could be implemented I would greatley appreciate it, Thank you so much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为cheedep的评论是正确的。以下是我将如何修改您的代码来做到这一点。您需要将 AxisScrollBarClicked 事件连接到图表。
I think cheedep's comment is correct. Here is how I would modify your code to do it. You will need to hook up the AxisScrollBarClicked event to your chart.