WPF中的图表缩放 [英] Chart scaling in WPF
问题描述
大家好,
我有一个图表线(例如,窦)作为WPF折线对象呈现.现在,我有一个画布对象要在其上放置该行.
canvas1.Children.Add(myPolyline);
现在在画布上显示了窦,但是只有一个小(小)曲线在画布上.有没有办法缩放折线,使其适合整个画布?我必须自己计算该转换,还是WPF中有任何支持.
任何帮助都将非常有用.
干杯,
Franz
Hi together,
I have got a chart line (e.g. a sinus) which is presented as a WPF polyline object. Now I have a canvas object where I want to put that line on.
canvas1.Children.Add(myPolyline);
Now the sinus is shown on the canvas, but only a small (little) curve on the canvas. Is there a way to scale that polyline so that it fits on the whole canvas? Do I have to calculate that transformation by myself or is there any support in the WPF.
Any help would be great.
Cheers,
Franz
推荐答案
画布支持显式布局(您必须显式指定x和y坐标).这几乎意味着,您需要检测画布大小何时更改,并适当地缩放线条.
Canvas supports explicit layout (you have to specify the x and y coordinates explicitly). This pretty much means, you need to detect when the canvas size changes and scale your line appropriately.
为什么不将行添加到隐式提供布局支持的面板类型中(例如DockPanel,GridPanel等)?
Why don't you add the line into a panel type that provides layout support implicitly (e.g. DockPanel, GridPanel, etc)?
这篇关于WPF中的图表缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!