计算折线图上两点的角度
我想获得折线图上两点的角度。 我知道如何计算角度,问题是我需要 seriescollection.point 的 x 和 y,但我不知道如何获取它。
有人可以帮我吗?
编辑:
Jean-François Corbett 向我展示了如何获取点,我的意思是从顶部和左侧,而不是图表上的点(在 X 比例和 Y 比例上),尽管它可以工作。 我算错了。如何计算下图中的角度?
I want to get the angle of two points on a Line chart.
I know how to calculate an angle, the problem is that I need the x and y of the seriescollection.point and I have no idea how to get it.
Can someone help me with it?
EDIT:
Jean-François Corbett showed me how to get the points, I meant from top and left, and not point on the graph (on X scale and Y scale) though it can work.
I calculate it wrong. how can I calculate the angles in the picture below?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您询问如何获取图表系列中点的 (x,y) 坐标。方法如下:
编辑 据我从编辑的问题中可以看出,OP现在想要每个点的像素坐标,原点位于绘图的左上角。为此,您只需按轴宽度和跨度进行缩放即可。对于线图(我讨厌),x 轴有点棘手,因为没有最小或最大比例属性;必须使用“类别”的数量来代替。以下代码执行此缩放:
请注意,
y
沿绘图上的负 y 方向增加,因为您希望原点位于左上角。使用此
x
和y
,您可以计算屏幕上看到的角度。You ask how to get the (x,y) coordinates of points in a chart series. Here is how:
EDIT As far as I can tell from the edited question, OP now wants the pixel coordinates of each point, with origin at the top left of the plot. To do so, you just need to scale by the axis width and span. The x axis is a bit tricky in the case of line plots (which I hate), because there is no min or max scale property; have to use the number of "categories" instead. The following code does this scaling:
Note that
y
increases along the negative y direction on the plot, since you want the origin to be at the top left.Using this
x
andy
, you can calculate your angle as seen on the screen.X 和 Y 值不能直接从 Point 对象访问(据我所知),但它们代表传递的实际值到图表。尝试从存储它们的工作表中访问它们。
如果该方法不可用,请尝试使用
Series.values
(它返回 Y 值数组)和Series.XValues
(它返回 X 值数组)。 (请参阅 MSDN 参考)The
X
andY
values are not directly accessible from thePoint
object, (as best as I can tell), but they represent actual values passed to the graph. Try accessing them from the worksheet where they are stored.If that is unavailable, try
Series.values
, which returns an array of Y-values, andSeries.XValues
, which returns an array of X-values. (See MSDN Reference)