MS图,X轴日期和光标的相互作用时,X值是索引 [英] MS Chart, X axis dates and cursor interaction when X value is indexed
问题描述
下午好,
哗一下标题。
基本上这里的事情。
如果有一个时间序列是不连续的。
If have a time series which is not continuous.
因此,因为我用的是系列的IsXValueIndexed属性(设置为true)折叠单独点之间的空间。
Hence, since I use the IsXValueIndexed property of the Series (set to true) to collapse the space between the separate points.
这工作得很好,但我现在想能恢复点的细节,从图中(X和Y值),并在窗体上的标签显示出来。
That works fine, however I would now like to be able to recover a point's detail in from the graph (X and Y values) and display them in a label on the form.
因此,我用了以下事件:
Hence, I use the following event:
void myChart_CursorPositionChanging(object sender, CursorEventArgs e)
{
if (!double.IsNaN(e.NewPosition))
{
if (e.Axis.AxisName == AxisName.X)
{
lbl_selDate.Content = DateTime.FromOADate(e.NewPosition);
}
else
{
lbl_selValue.Content = e.NewPosition;
}
}
}
现在的问题是,该日期不正确...我无法找到合适的转换方法来恢复这该死的时间戳。
The problem is that the date is incorrect... I cannot find the right conversion method to recover this damned timestamp.
你任何机会可以帮我?
谢谢!
雷米
推荐答案
假设你有DateTime类型x轴然后使用:
suppose you have x-axis of type DateTime then use:
DateTime xValue = DateTime.FromOADate(((Chart)sender).Series[0].Points[(int)e.NewPosition - 1].XValue)
假设你有型的Y轴双然后使用:
suppose you have y-axis of type double then use:
double yValue = ((Chart)sender).Series[0].Points[(int)e.NewPosition - 1].YValues[0];
这篇关于MS图,X轴日期和光标的相互作用时,X值是索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!