简体   繁体   English

关于如何在WPF中放大Chart控件的想法

[英]Ideas on how to zoom on a Chart control in WPF

summarizing I have implemented a chart control as a simple Canvas with a Polyline on it. 总结我已经将图表控件实现为带有折线的简单Canvas。 The next thing I need is to be able to zoom the chart. 接下来,我需要放大图表。

I would like to know how would you that (just the idea, no details needed). 我想知道您的想法(只是想法,不需要任何细节)。 What I would like to do is to create somehow a bigger Canvas and paint the line bigger and just show a part of the Canvas to the user, and the he drags the Chart it will move the Canvas. 我想做的是以某种方式创建一个更大的Canvas,并绘制更大的线条,并向用户显示Canvas的一部分,然后他拖动Chart将移动Canvas。 Something like in the following picture. 如下图所示。 Do you think this is possible? 您认为这可能吗?

在此处输入图片说明

Kael Rowan from Microsoft Research built a ZoomableCanvas class that may do exactly what you want. Microsoft Research的Kael Rowan构建了一个ZoomableCanvas类 ,它可以完全满足您的要求。 You can also see all the posts he wrote about it . 您还可以查看他撰写的所有帖子 You can even try a running XBAP example if your browser supports it. 如果您的浏览器支持,您甚至可以尝试运行XBAP示例

We use the RenderTransform for this, create your zoom and pan matrix( or transform ) and apply that to your canvas. 为此,我们使用RenderTransform ,创建缩放和平移矩阵(或transform)并将其应用于画布。 The nice thing is, that you can still have elements that can display behind or on top of the canvas with the identity transform or with another. 令人高兴的是,您仍然可以具有可以通过身份转换或其他方式显示在画布后面或上面的元素。 For example for a grid or screen space elements like a minimap, which should always be visible. 例如,对于网格或屏幕空间元素(如小地图),应始终可见。 You might also want to look into this old question, which is somehow related. 您可能还想研究这个旧问题,这在某种程度上是相关的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM