Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Irregular interval on DateTime Axis in OxyPlot

Tags:

c#

wpf

oxyplot

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:

enter image description here

This is the interval when the chart starts plotting.

After a while the interval is like this:

enter image description here

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

like image 289
Abhishek Avatar asked Sep 22 '14 08:09

Abhishek


1 Answers

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,
};
like image 200
AwkwardCoder Avatar answered Oct 13 '22 20:10

AwkwardCoder