-
Notifications
You must be signed in to change notification settings - Fork 980
Closed
Description
Steps to reproduce
Create an empty model with a range-constrained axis but no data, like so:
var pm = new PlotModel();
pm.Axes.Add(new LinearAxis
{
Position = AxisPosition.Bottom,
AbsoluteMinimum = -200.0,
AbsoluteMaximum = -100.0,
MinimumRange = 10.0,
});
plot1.Model = pm;I used the WindowsFormsDemo but many of the examples should be usable as well.
Platform: OxyPlot.WinForms on Windows 10 64 bit
.NET version: 4.8
Expected behaviour
I would expect the axis to honour the absolute limits and the minimum range, so any of these visible ranges would be fine:
[-200.0, -100.0][-200.0, -190.0][-155.0, -145.0][-110.0, -100.0]
Actual behaviour
Instead I get the range [-100.0, -99.0] which violates both the AbsoluteMaximum and the MinimumRange properties:
Cause and proposed fix
The problem is the following code in Axis.cs:
protected virtual void CoerceActualMaxMin()
{
// Coerce actual minimum
if (double.IsNaN(this.ActualMinimum) || double.IsInfinity(this.ActualMinimum))
{
this.ActualMinimum = 0;
}
// Coerce actual maximum
if (double.IsNaN(this.ActualMaximum) || double.IsInfinity(this.ActualMaximum))
{
this.ActualMaximum = 100;
}which uses values outside the allowed range. A possible fix would be to change this to:
this.ActualMinimum = Math.Max(0, this.AbsoluteMinimum);and
this.ActualMaximum = Math.Min(100, this.AbsoluteMaximum);respectively. With these changes I get the initial display range [-110.0, -100.0] which is valid.
Reactions are currently unavailable
