User interactive Graph from DataGridView

前端 未结 1 1921
南旧
南旧 2021-01-16 18:15

I have a DataGridView that displays information that is read from a txt file. My aim is to create a line graph for this data which displays DateTime for the X axis.

相关标签:
1条回答
  • 2021-01-16 18:35

    Your question seems to have several parts. I'll try to help with each..

    The last part in your question is solved like this:

    Assuming you have a Chart with the DataPoints set and showing the line, you can use this:

     Series S = chart1.Series[0];  // short reference
     S.ToolTip = "#VALX{#.##}" +  " : " +  "#VALY1{#.##}";
    

    to display the x- and y-values as tooltips in a format you like.

    enter image description here

    See MSDN for a full list of keywords to use in referring to the DataPoints

    If you want to display data that are not part of the DataPoint's data you can instead create individual ToolTips for each DataPoint when you add it:

    double dx = yourXValue;
    double dy = yourYValue;
    DataPoint dp = new DataPoint(dx, dy);
    dp.ToolTip =  yourToolTip;
    S.Points.Add(dp);
    

    You will have to create the ToolTip readily formatted for each DataPoint!

    If other parts are still open, please say so!

    0 讨论(0)
提交回复
热议问题