X轴类型为DateTime
。我想知道如何从与我的系列中的点对应的x轴上的double值中提取原始DateTime
值?
我可以用
添加点数point->SetValueXY(xdateTime,yvalue);
chart1->Series[0]-Add(point);
答案 0 :(得分:0)
试试这个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);
}
}