c# - oxyplot Axis 在鼠标滚轮时锁定中心

标签 c# axis mousewheel oxyplot

我是 wpf 和 oxyPlot 的新手。 现在,我想创建一个像示波器一样的动态折线图,但我不知道如何在鼠标滚轮缩放时将 Axis 锁定在某个值上。

示例:

enter image description here

红点是鼠标所在位置。正常情况下,缩放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/

相关文章:

c# - quartz : Does not implement interface member

c# - 自动化测试工具

java - AXIS Web 服务未使用 Weblogic 服务器上定义的信任库

python - tkinter:将鼠标滚轮绑定(bind)到滚动条

javascript - 如何在没有库的情况下检测各种滚动?

c# - 如何获取 OAuth AccessToken (google) 以在 C# 中向 Google Hire 发布工作?

c# - 无法使用带有汉字 Json 数据的 Azure Active Directory B2C Graph API 创建新用户

Java 生成 WSDL 但无法使用 ?wsdl 访问它

iOS Core Plot with Swift - 格式化 Axis

delphi - 如何在 TcxComboBox 中抑制鼠标滚轮