Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am able to get correct y coordinate value but x coordinate is always zero.
how to rectify it, below is the code which i am using to get tooltip

C#
<pre lang="cs">Point? clickPosition = null;
        ToolTip tooltip = new ToolTip();
private void chart1_MouseMove(object sender, MouseEventArgs e)
{

    var pos = e.Location;
    clickPosition = pos;
    var results = chart1.HitTest(pos.X, pos.Y, false,
                                 ChartElementType.DataPoint);
    foreach (var result in results)
    {
        if (result.ChartElementType == ChartElementType.DataPoint)
        {

            int index = result.PointIndex;


         

            tooltip.Show(&quot;X=&quot; + result.Series.Points[result.PointIndex].XValue + &quot;,\nY=&quot; + result.Series.Points[result.PointIndex].YValues[0],
                         this.chart1, e.Location.X, e.Location.Y - 15);
        }
        else
        {
            tooltip.Hide(this.chart1);
        }
    }
}</pre>
Posted
Updated 28-Jul-15 19:21pm
v2
Comments
Ralf Meier 29-Jul-15 3:53am    
I think, that your are not exactly positioned on the Chart-Graph with you Mouse-Pointer.
Perhaps you should try it with a little range around the actual Mouse-Coordinates ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900