Irregular spacing on DateTime axis in OxyPlot

I have a WPF application in which I am using OxyPlot for charting. I am constantly adding points to lines in a chart. X-Axis is a DateTime axis, the type of interval is set in seconds. Points are added continuously to the ruler. When the time between the first and last point is a certain number of seconds, I delete the first point and cancel the graph. This makes the X-Axis scroll. I noticed that the Interval is not regular. The interval sometimes changes. See the following images:

enter image description here

This is the interval when the chart starts from the graph.

After a while, the interval looks like this:

enter image description here

How do I make the fixed spacing the same as in the first image?

+3


source to share


1 answer


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

eg. below I create and an x-axis that represents "End of Day", where the interval is Day and the minimum interval is also a day, this prevents trying to show half or a quarter of the days when I zoom in on the graph.



_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,
};

      

+6


source







All Articles