【发布时间】:2014-02-22 13:37:08
【问题描述】:
X 轴类型为DateTime。我想知道如何从与我的系列中的点对应的 x 轴上的双精度值中提取原始 DateTime 值?
我可以用
加点point->SetValueXY(xdateTime,yvalue);
chart1->Series[0]-Add(point);
【问题讨论】:
标签: c++ .net visual-studio mschart
X 轴类型为DateTime。我想知道如何从与我的系列中的点对应的 x 轴上的双精度值中提取原始 DateTime 值?
我可以用
加点point->SetValueXY(xdateTime,yvalue);
chart1->Series[0]-Add(point);
【问题讨论】:
标签: c++ .net visual-studio mschart
试试这个 C# 代码,它应该会给你一个开始。我用它向Label 添加文本,将x 值显示为日期,将y 值显示为数字。希望这会有所帮助
public void Cht_Click(object sender, System.Windows.Forms.MouseEventArgs e)
{
//Call HitTest()
HitTestResult result = sender.HitTest(e.X, e.Y);
//If the mouse if over a data point
if (result.ChartElementType == ChartElementType.DataPoint) {
//Reset Data Point Attributes
DataPoint point = default(DataPoint);
//Find selected data point
point = result.Series.Points(result.PointIndex);
//extract x value
System.DateTime _date = System.DateTime.FromOADate(point.XValue);
Label24.Text = "Date: " + Strings.Format(_date, "dd/MM/yy") + " Value: " + point.YValues(0);
}
}
【讨论】: