Question

X axis type is DateTime. I want to know how to extract original DateTime value from the double value on the x axis corresponding to the point in my series?

I can add point with

point->SetValueXY(xdateTime,yvalue);
chart1->Series[0]-Add(point);
Was it helpful?

Solution

Try this C# code, it should give you a start. I use it to add text to a Label thats shows the x value as date and the yvalue as a number. Hope this helps

Chart Click GIF

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);

}

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top