Question

I'm using C# chart control to draw a nyquist plot. Now i want data points appear on the curve each time the user moves the mouse on it. So i used hit test method in GetToolTipText event.

private void BodePlot_GetToolTipText(object sender, ToolTipEventArgs e)
        {
            HitTestResult result = BodePlot.HitTest(e.X, e.Y);
            selectDataPoint = null;

            if (result.ChartElementType == ChartElementType.DataPoint)
                {
                    selectDataPoint = (DataPoint)result.Object;
                    e.Text = selectDataPoint.ToString();
                }
         {

The problem is only a part of the curve shows values, others don't. When i use e.Text = result.Object.ToString(); to get the object on which the mouse is pointing to, here what i found :

enter image description here

Instead of showing the data points, the text on tooltip show custom label. So i guess the reason is that the curve is covered by the labels of x and y axis.

The only solution that i found is disabling the x and y axis, with that everything works fine. But i want to keep those axes, so how can i make those labels hide under the curve.

Était-ce utile?

La solution

Your analysis is likely correct. The way to go around this would be to provide HitTest() with the optional third argument which define the desired element type.

public HitTestResult HitTest (
int x,
int y,
ChartElementType requestedElement
)

This should return underlying data points even if other elements are overlapping them.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top