Irregular interval on DateTime Axis in OxyPlot

这一生的挚爱 提交于 2019-12-07 17:52:03

问题


I have a WPF application in which I am using OxyPlot for charting. I add points continuously to the lineseries in the chart. The X-Axis is a DateTime axis whose interval type is set to seconds. Points are added continuously to the line series. When the timespan between first and last point is a particular number of seconds, I remove the first point and Invalidate the plot. This makes the X-Axis scroll. I have noticed that the Interval is not regular though. The interval changes sometimes. See the following images:

This is the interval when the chart starts plotting.

After a while the interval is like this:

How do I make the interval fixed that is as in the first image?


回答1:


You need to set the properties of the x-axis object.

e.g. below I'm creating and x-axis which represents the 'End of Day' where the interval is a Day and the minimum interval is also a day, this prevent it trying to show half or quarter days when I zoom into the plot.

_xAxis = new DateTimeAxis
{
    Position = AxisPosition.Bottom,
    StringFormat = Constants.MarketData.DisplayDateFormat,
    Title = "End of Day",
    IntervalLength = 75,
    MinorIntervalType = DateTimeIntervalType.Days,
    IntervalType = DateTimeIntervalType.Days,
    MajorGridlineStyle = LineStyle.Solid,
    MinorGridlineStyle = LineStyle.None,
};


来源:https://stackoverflow.com/questions/25969656/irregular-interval-on-datetime-axis-in-oxyplot

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