我是 wpf 和 oxyPlot 的新手。 现在,我想创建一个像示波器一样的动态折线图,但我不知道如何在鼠标滚轮缩放时将 Axis 锁定在某个值上。
示例:
红点是鼠标所在位置。正常情况下,缩放A -> B,缩放C -> D。现在,我想缩放C ->E,就像鼠标位于0中心一样。
最佳答案
我找到了一个可以阻止 Axis 缩放中心的解决方案。您必须创建一个自定义 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。
关于c# - oxyplot Axis 在鼠标滚轮时锁定中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41565360/