MS 图表和 NaN
我正在使用带有 C# 的 MS Chart,当我尝试从图表中检索几乎所有元值时遇到问题,我得到的只是 NaN。几个例子...
void chart_CursorPositionChanged(object sender, CursorEventArgs e)
{
double selectStart = e.NewSelectionStart;
double selectEnd = e.NewSelectionEnd;
}
e.NewSelectionStart and e.NewSelectionEnd both show NaN for their values.
另一个例子...
chart.ChartAreas[0].AxisX.Maximum
也是 NaN。但是,如果我将其设置为一个值,图表将正确反映它。有什么想法我做错了吗?
I'm using MS Chart with C# and I'm having issues when I try to retrieve almost any meta values from the chart, all I am getting is NaN. Couple of examples...
void chart_CursorPositionChanged(object sender, CursorEventArgs e)
{
double selectStart = e.NewSelectionStart;
double selectEnd = e.NewSelectionEnd;
}
e.NewSelectionStart and e.NewSelectionEnd both show NaN for their values.
Another example...
chart.ChartAreas[0].AxisX.Maximum
is also NaN. However, if I set it to a value the chart properly reflects it. Any ideas what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您可能没有正确初始化
chart.ChartAreas[0]
:您是否将Cursor.IsUserSelectionEnabled
设置为 true?如果您尚未启用用户选择,则当用户单击并移动鼠标时,该事件仍会触发,但不会发生选择。
这意味着
图表将自行管理保证金。
It sounds like you might not be properly initializing
chart.ChartAreas[0]
: Have you setCursor.IsUserSelectionEnabled
to true?If you haven't enabled user selecting then the event will still fire when a user clicks and moves the mouse, but a selection won't take place.
As for
This means that the chart will manage the margin itself.
不要像您当前那样使用 CursorEventArgs 提供的数据,而是执行以下操作:
我今天遇到了与您相同的问题,这为我解决了它。我不知道为什么 CursorEventArg 数据返回 NaN
Instead of using the data provided by CursorEventArgs like you currently are, do this:
I experienced the same problem as you today, and this solved it for me. I dont know why the CursorEventArg data returns an NaN though