在鼠标点击时在ms图表中获得标记位置 [英] get mark position in ms charts on mouse click

查看:260
本文介绍了在鼠标点击时在ms图表中获得标记位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MS图表制作图表。
现在,如果用户点击标记点,图表中有我想要获取坐标
的标记点。

I m making a chart using MS Charts. Now the chart has mark points from where i want to get the coordinates if user clicks on the mark points.

我想在图表,使得在点击标记点时,我可以找到标记点的线迹(x轴和y轴)。

I want interactivity in the chart such that on clicking on the mark points i can retrive the cordinates (x-axis and y-axis) for the mark points.

例如:

点击橙色点或蓝色点,我想获得该点的线段,

on clicking on the orange dots or blue dots i want to get the cordinates for that point,

例如,第一个蓝点是/ 11/2011,49)

for example the first blue point is (10/11/2011, 49)

感谢

推荐答案

<pre>void chart_MouseDown(Object sender, System.Windows.Forms.MouseEventArgs e)
{
    HitTestResult result = chart.HitTest(e.X, e.Y);
    switch(result.ChartElementType)
    {
    case case ChartElementType.DataPointLabel:
        DateTime start = DateTime.FromOADate(result.Series.Points[result.PointIndex].XValue);
        ...
        break;
    }
}</pre>

这篇关于在鼠标点击时在ms图表中获得标记位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆