Skip to content

Commit

Permalink
Respect MinimumRange values when Minimum and Maximum values are also set
Browse files Browse the repository at this point in the history
Resolves oxyplot#550.
  • Loading branch information
classicboss302 committed Oct 19, 2015
1 parent 62b6318 commit 1161d2d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ All notable changes to this project will be documented in this file.
- Fix null reference exception when ActualPoints was null rendering a StairStepSeries (#582)
- Background color in the Xamarin.Forms views (#546)
- IsVisible change in Xamarin.Forms.Platform.iOS (#546)
- Fix issue with MinimumRange not taking Minimum and Maximum values into account (#550)

## [2014.1.546] - 2014-10-22
### Added
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Brannon King
Brian Lim <[email protected]>
Caleb Clarke <[email protected]>
Carlos Teixeira <[email protected]>
classicboss302
Cyril Martin <[email protected]>
darrelbrown
David Laundav <[email protected]>
Expand Down
15 changes: 15 additions & 0 deletions Source/Examples/ExampleLibrary/Axes/AxisExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,21 @@ public static PlotModel AbsoluteMinimumAndMaximum()
return model;
}

[Example("MinimumRange with Minimum")]
public static PlotModel MinimumRangeWithMinimum()
{
var model = new PlotModel { Title = "MinimumRange of 5 with a Minimum of 0", Subtitle = "Should show a range from 0 to 5" };
model.Axes.Add(
new LinearAxis
{
Position = AxisPosition.Left,
Minimum = 0,
MinimumRange = 5
});

return model;
}

[Example("Title with unit")]
public static PlotModel TitleWithUnit()
{
Expand Down
3 changes: 1 addition & 2 deletions Source/Examples/WPF/WpfExamples/WpfExamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -503,5 +503,4 @@
<Folder Include="Workitems\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
19 changes: 15 additions & 4 deletions Source/OxyPlot/Axes/Axis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -722,10 +722,21 @@ public virtual void CoerceActualMaxMin()
var range = this.ActualMaximum - this.ActualMinimum;
if (range < this.MinimumRange)
{
var average = (this.ActualMaximum + this.ActualMinimum) * 0.5;
var delta = this.MinimumRange / 2;
this.ActualMinimum = average - delta;
this.ActualMaximum = average + delta;
if (!double.IsNaN(this.Minimum) && !double.IsNaN(this.Maximum))
{
var average = (this.ActualMaximum + this.ActualMinimum) * 0.5;
var delta = this.MinimumRange / 2;
this.ActualMinimum = average - delta;
this.ActualMaximum = average + delta;
}
else if (!double.IsNaN(this.Minimum) && double.IsNaN(this.Maximum))
{
this.ActualMaximum = this.Minimum + this.MinimumRange;
}
else if (!double.IsNaN(this.Maximum) && double.IsNaN(this.Minimum))
{
this.ActualMinimum = this.Maximum - this.MinimumRange;
}
}

if (this.AbsoluteMaximum <= this.AbsoluteMinimum)
Expand Down

0 comments on commit 1161d2d

Please sign in to comment.