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?
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,
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With