我是 wpf 和 oxyPlot 的新手。
现在,我想创建一个像示波器一样的动态折线图,但我不知道如何在鼠标滚轮缩放时将轴锁定在某个值上。
Example:
红点是鼠标所在位置。正常情况下,缩放A -> B,缩放C -> D。现在,我想缩放C ->E,就像鼠标位置在0中心一样。
我找到了一种可以阻止轴缩放中心的解决方案。你必须创建一个自定义的LinearAxis
为了达成这个:
public class FixedCenterLinearAxis : LinearAxis
{
double center = 0;
public FixedCenterLinearAxis() : base(){}
public FixedCenterLinearAxis(double _center) : base()
{
center = _center;
}
public override void ZoomAt(double factor, double x)
{
base.ZoomAt(factor, center);
}
}
你必须像这样使用它:
var bottomAxis = new FixedCenterLinearAxis(0.5) //specify the center value here
{
Position = AxisPosition.Bottom,
};
plotModel.Axes.Add(bottomAxis);
如果您未在构造函数中指定值,则中心值为 0。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)