鼠标滚轮时,oxyplot轴锁定中心 [英] oxyplot axis locking center when mouse wheel

查看:399
本文介绍了鼠标滚轮时,oxyplot轴锁定中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm new to wpf and oxyPlot. Now, I want create a dynamic line chart like an oscilloscope, but I don't know how to lock the axis on a value when mouse wheel zooms.

示例:

红点是鼠标位置.正常情况下,先放大A-> B,再放大C->D.现在,我要放大C-> E,就像鼠标在0中心位置一样.

The red point is mouse location. In normal, zoom A -> B, zoom C -> D. now, I want to zoom C ->E, like mouse location at 0 center.

推荐答案

我找到了一种可用于阻止轴缩放中心的解决方案.您必须创建一个自定义LinearAxis来实现此目的:

I've found a solution that works for blocking an axis zoom center. You have to create a custom LinearAxis to achieve this:

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.

If you dont specify a value on the constructor, center value will be 0.

这篇关于鼠标滚轮时,oxyplot轴锁定中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆