是否可以在图表元素上绘制矩形?

发布于 2024-12-10 11:11:11 字数 482 浏览 0 评论 0原文

我有一些像这样绘制时间序列散点图的 XAML(X 轴:日期时间,Y 轴:整数值):

<Grid Name="chartgrid">
    <charting:Chart Name="scatterplot">
    </charting:Chart>
</Grid>

我能够将图形对象(例如线条)添加到该网格作为其子项之一,但有使用与图表控件使用的不同的 XY 坐标来执行此操作。当然,这是预期的,因为图表设置了自己的轴。

我能想到的唯一方法是在图表中添加一些虚拟点作为不同的系列,但我希望有更好的方法来做到这一点。有什么建议吗?

编辑:添加了一个数字以进一步澄清。

在此处输入图像描述

I have some XAML like this drawing a scatterplot of a time series (X-Axis: DateTime, Y-Axis: Integer Value):

<Grid Name="chartgrid">
    <charting:Chart Name="scatterplot">
    </charting:Chart>
</Grid>

I am able to add a graphic object such as a line to this grid as one of its children but have to do so using X and Y coordinates that are different from the ones used by the chart control. Of course this is expected because the chart sets up its own axis.

The only approach I could think of is to add some dummy points to the graph as a different series but am hoping there is a better way to do this. Any suggestions?

EDIT: Added a figure to clarify further.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

饮湿 2024-12-17 11:11:11

我能想到的唯一方法是检查虚拟树以查找两个轴对象。

也许通过使用 VisualTreeHelper

一旦您知道它们的位置和大小,并结合您可以从图表控件中获得的比例信息,您就可以计算从图表点到 Silverlight 坐标的转换。

The only way I can think of is by examining the Virtual Tree looking for both axis objects.

Perhaps by using the VisualTreeHelper

Once you know their positions and their sizes combined with the scale information you can hopefully get from the chart control you could calculate the transformation from chart point to Silverlight coordinate.

谢绝鈎搭 2024-12-17 11:11:11

你想用矩形来装饰网格吗?如果是这样为什么不使用边框呢? ...(抱歉,我还没有发表评论的选项。因此我问你这个问题作为答案)

Are you tying to adorn the Grid with a rectangle? If so why not using a border? ... (Sorry I dont have option to comment yet. Hence I asked you this question as an answer)

淡写薰衣草的香 2024-12-17 11:11:11

我会创建一个 Adorner 来执行实际的操作绘制你的覆盖物。在图表控件中创建此层,或封装两者的类。并为 Chart 类提供正确的 Matrix变换 转换叠加层中的给定坐标对象到当前图表 转换。 TransformToDescendant 也很有帮助,它允许您例如,将图表中的点转换为装饰器。

我不知道你在图表 IScrollInfo、RenderTransform 等上转换什么以及如何转换位置。但有了这些信息,我认为你可以实现你正在寻找的东西。

I would create an Adorner to do the actual drawing of your overlay stuff. Create this layer in your Chart control, or a class that encapsualtes both. And give the Chart class the proper Matrix or Transform to convert the given coordinates in your overlay objects to the current Chart transform. Also helpful is TransformToDescendant which allows you to convert a point from your chart for example, to your adorner.

I don't know what and how you transform the position on your chart IScrollInfo, RenderTransform etc. But with this information i think you can achieve what you are looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文