Exemplo n.º 1
0
        void Chart1_MouseMove(object sender, MouseEventArgs e)
        {
            ChartGroup grp = Chart1.ChartGroups.Group0;

            ps = grp.ChartData.PointStylesList[0];
            // if both are changed to valid values, then something needs to be highlighted
            int seriesIndex = -1, pointIndex = -1;


            // check if the mouse is in the PlotArea.
            if (Chart1.ChartRegionFromCoord(e.X, e.Y) == ChartRegionEnum.PlotArea)
            {
                int dist = 0;

                // find the closest XCoord.
                if (grp.CoordToDataIndex(e.X, e.Y, CoordinateFocusEnum.XCoord, ref seriesIndex, ref pointIndex, ref dist))
                {
                    // if there are multiple series in the chart, then find the closest series.
                    if (grp.CoordToSeriesIndex(e.X, e.Y, PlotElementEnum.Series, ref seriesIndex, ref dist))
                    {
                        ps.PointIndex  = pointIndex;
                        ps.SeriesIndex = seriesIndex;
                        label3.Text    = tlist[pointIndex].ToString();
                        label4.Text    = ylist[pointIndex].ToString();
                    }
                }

                if (seriesIndex == -1 || pointIndex == -1)
                {
                    ps.PointIndex  = -1;
                    ps.SeriesIndex = -1;
                }
            }
        }