oxyplot axis locking center when mouse wheel

…衆ロ難τιáo~ 提交于 2019-12-20 04:23:35

问题


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.

Example:

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.


回答1:


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);
    }
}

You have to use it like that:

var bottomAxis = new FixedCenterLinearAxis(0.5) //specify the center value here
{
    Position = AxisPosition.Bottom,
};

plotModel.Axes.Add(bottomAxis);

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



来源:https://stackoverflow.com/questions/41565360/oxyplot-axis-locking-center-when-mouse-wheel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!