缩放 Silverlight Toolkit 图表?

发布于 2024-10-03 17:58:34 字数 206 浏览 3 评论 0 原文

我需要在我使用的 Silverlight 图表上启用缩放功能 - 目前这是 Silverlight Toolkit。据我所知,SL Toolkit 图表不支持缩放,但我正在考虑实现此功能。到目前为止,我还没有取得多大进展:将 ScaleTransforms 应用于 Series 元素并不能按预期工作。

谁能给我提供在 Silverlight Toolkit 中实现缩放的示例代码?

I need to enable zooming on the Silverlight charts I use - at the moment this is Silverlight Toolkit. As far as I've understood the SL Toolkit charts don't support zooming, however I'm looking into implementing this functionality. So far I haven't managed to get far: applying ScaleTransforms to the Series elements doesn't work as expected.

Can anyone provide me with example code on implementing zooming in Silverlight Toolkit?

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

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

发布评论

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

评论(3

以为你会在 2024-10-10 17:58:34

我之前曾研究过在 Silverlight Toolkit 图表上实现缩放,但由于(可能)以下原因而失败:

  • Silverlight Toolkit 图表似乎没有被设计为能够扩展缩放 。没有任何钩子可以让您轻松攻击某些缩放逻辑,如果您想在它们上创建缩放,则必须付出更多努力。
  • 实现缩放的最简单方法是对元素使用 ScaleTransform 和 RenderTransform。如果是 Silverlight Toolkit,您希望将其应用于该系列。然而,仅仅计算正确的 ScaleTransform 和 OffsetTransform 就已经很困难了
  • 。缩放时,您不希望所有内容都缩放。如果将带有点的线系列放大 4 倍,您不希望线变粗 4 倍,点变大 4 倍。这意味着即使您确实正确地应用了 ScaleTransforms 和 RenderTransforms,您得到的只是一个放大镜,这仍然远非理想。

几个小时后,我放弃了向 SL 工具包图表添加这种支持,而是寻找其他支持缩放并具有不错的 API 来处理它的组件。这些是我找到的组件(尽管我确信还有更多):

总而言之,我认为使用已经实现缩放的组件的最简单方法 - 根据我的经验,需要大量投资才能向 Silverlight Toolkit 图表添加适当的缩放和平移。

I've previously looked into implementing zooming on the Silverlight Toolkit charts, however failed because of (probably) the following reasons:

  • Silverlight Toolkit charts don't seem to have been designed to be able to extend for zooming. There are no hooks that you could easily attack some zooming logic to, if you want to create zooming on them, you have to go much deeer.
  • The simplest way of implementing zooming is using ScaleTransform and RenderTransform to elements. In case of Silverlight Toolkit you want to apply this to the series. However just calculating the correct ScaleTransform and OffsetTransform are difficult enough
  • When scaling, you don't want everything to scale. If you zoom in 4x on a line series with points on it, you don't want the line to be 4x thicker and the points to be 4x larger. This means that even if you did implement applying the ScaleTransforms and RenderTransforms correctly, all you would get is a magnifying glass, which is still far from ideal.

After a few hours I gave up on adding this kind of support to the SL toolkit charts and instead looked for other components that support zooming and have a decent API to deal with it. These are the components I've found (though I'm sure there's more):

Summing it up, I think the easiest way for you to go it with a component that already has zooming implemented - from my experience it would take a lot of investment to add proper zooming + panning to Silverlight Toolkit charts.

童话里做英雄 2024-10-10 17:58:34

添加关于 Telerik 的 Gergely Orozy 评论:

您可以使用以下 XAML 轻松添加 Zoom 功能。

<charting:ChartArea.ZoomScrollSettingsX>
    <charting:ZoomScrollSettings ScrollMode="ScrollAndZoom" MinZoomRange="0.005"/>
</charting:ChartArea.ZoomScrollSettingsX>

您可以点击此处查看演示,源代码也可以在该链接上找到相同的选项卡。

Adding to Gergely Orozy comment about Telerik:

You can easily add the Zoom functionality with the following XAML.

<charting:ChartArea.ZoomScrollSettingsX>
    <charting:ZoomScrollSettings ScrollMode="ScrollAndZoom" MinZoomRange="0.005"/>
</charting:ChartArea.ZoomScrollSettingsX>

You can check out a demo by clicking here and the source code is also available on that same tab.

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