在MSChart中获取数据点的屏幕X,Y. [英] Get screen X,Y of datapoint in MSChart

查看:154
本文介绍了在MSChart中获取数据点的屏幕X,Y.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让MSChart DataPoint的屏幕协调?

解决方案

  Dim  mypoint  As  Point 
mypoint = Cursor.Position





您可以从中获取鼠标位置。如果这是关于图表的具体信息,您可以去看 http://msdn.microsoft.com/en-us/library/aa231230%28v=vs.60%29.aspx [ ^ ]。



祝你好运!


如果X轴和Y轴的比例都是线性的,你可以执行
以下内容:

在图表的Paint事件例程中,使用ValueToPixelPosition可以找到Y-top和Y-bottom
,如下所示:

intYTop = msChart.ChartAreas(0).AxisY.ValueToPixelPosition(msChart.ChartAreas(0).AxisY.Maximum)
intYBot = msChart.ChartAreas(0).AxisY.ValueToPixelPosition(msChart.ChartAreas(0) .AxisY.Minimum)
intYlen = intYBot - intYTop
intYMaxV = msChart.ChartAreas(0).AxisY.Maximum'最大Y值
'*
t的开头他通过以下方式获得X轴和两个X-MajorTickMark之间的差异:
intXLft = msChart.ChartAreas(0).ValueToPixelPosition(msChart.ChartAreas(0).AxisX.Minimum)
intXint = msChart。 ChartAreas(0).ValueToPixelPosition(2) -
msChart.ChartAreas(0).ValueToPixelPosition(1)'Distance X-MajorTickMarks
'*
对于索引= intIndex和Y-的DataPoint value = Y-value x和ycoördinates是:
x = intXLft +(intIndex * intXint)
y = intYBot - (Y-value)/ intYMaxV)* intYlen)


Is there a way to get the screen coordination of an MSChart DataPoint?

解决方案

Dim mypoint As Point 
mypoint = Cursor.Position



You can get the mouse location from that. If that is specifically about the Charts you can go and see http://msdn.microsoft.com/en-us/library/aa231230%28v=vs.60%29.aspx[^] at the end of the page.

Good luck!


If the scale of the X-axis and Y-axis are both linear you can do
the following:

In the Paint event routine of the chart the Y-top and Y-bottom can
be found by using ValueToPixelPosition as follows:

intYTop = msChart.ChartAreas(0).AxisY.ValueToPixelPosition(msChart.ChartAreas(0).AxisY.Maximum)
intYBot = msChart.ChartAreas(0).AxisY.ValueToPixelPosition(msChart.ChartAreas(0).AxisY.Minimum)
intYlen = intYBot - intYTop
intYMaxV = msChart.ChartAreas(0).AxisY.Maximum    'Maximum Y-value  
'*
The start of the X-axis and the difference between two X-MajorTickMarks is obtained via:
intXLft =msChart.ChartAreas(0) .ValueToPixelPosition(msChart.ChartAreas(0).AxisX.Minimum)
intXint = msChart.ChartAreas(0).ValueToPixelPosition(2) -
          msChart.ChartAreas(0).ValueToPixelPosition(1) 'Distance X-MajorTickMarks
'*  
For a DataPoint with index = intIndex and Y-value = Y-value the x and y coördinates are:
x = intXLft + (intIndex * intXint) 
y = intYBot - (Y-value) / intYMaxV) * intYlen) 


这篇关于在MSChart中获取数据点的屏幕X,Y.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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