none
Dynamic Data Display 更改坐标轴的个数 RRS feed

  • 问题

  • Dynamic Data Display 更改坐标轴的个数,坐标轴太多了,我测试了DecreaseTickCount这个方法 没有效果
    2016年12月13日 8:41

全部回复

  • 你好,

    >>更改坐标轴的个数,坐标轴太多了
    如果是希望设定坐标轴范围,以下方法可以参考():
    写两个类:

            public class DisplayRange
            {
                public double Start { get; set; }
                public double End { get; set; }
                public DisplayRange(double start, double end)
                {
                    Start = start;
                    End = end;
                }
            }
            public class ViewportAxesRangeRestriction : IViewportRestriction
            {
                public DisplayRange XRange = null;
                public DisplayRange YRange = null;
    
                public Rect Apply(Rect oldVisible, Rect newVisible, Viewport2D viewport)
                {
                    if (XRange != null)
                    {
                        newVisible.X = XRange.Start;
                        newVisible.Width = XRange.End - XRange.Start;
                    }
    
                    if (YRange != null)
                    {
                        newVisible.Y = YRange.Start;
                        newVisible.Height = YRange.End - YRange.Start;
                    }
                    return newVisible;
                }
    
                public event EventHandler Changed;
            }

    设置范围:
                plotter.Viewport.AutoFitToView = true;
                ViewportAxesRangeRestriction restr = new ViewportAxesRangeRestriction();
                restr.XRange = new DisplayRange(0, 20);
                plotter.Viewport.Restrictions.Add(restr);

    设置成功后横坐标范围为0-20:

    如果不是要设置坐标轴显示范围,建议给出代码或图片说明问题。


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    2016年12月14日 9:25
    版主