小编han*_*oux的帖子

从X值获取.NET图表系列的Y值

使用C#与.NET图表.

我试图绘制几个波形图,我希望将鼠标移动到图表区域,并让我的工具提示在此X值位置显示图表中每个系列的Y值.

|      at xValue 12    |                                     |
|      _ = 3           |                                     |
|      * = 2           |                                * *  |
|              ________|______________________________*_____ |
|             /        |                             *       |
| __________*/*********|*****************************        |
|        *             |                                     |
|       *              |                                     |
|______________________|_____________________________________|
Run Code Online (Sandbox Code Playgroud)

有点像上图.以下是我的代码版本:

void chart1_MouseMove(object sender, MouseEventArgs e)
        {
            var pos = e.Location;
            _point.X = e.Location.X;
            _point.Y = e.Location.Y;

            try
            {
                if ((chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X) >= 0) && (chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X) <= max))
                {
                    //Crossair
                    chart1.ChartAreas[0].CursorX.SetCursorPixelPosition(_point, true);

                    //Tooltips
                    double xValue = chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X);
                    double yValue …
Run Code Online (Sandbox Code Playgroud)

.net c# tooltip mschart

5
推荐指数
1
解决办法
5861
查看次数

标签 统计

.net ×1

c# ×1

mschart ×1

tooltip ×1