summaryrefslogtreecommitdiff
path: root/grapher/Models/Charts
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-12-03 22:42:29 -0500
committera1xd <[email protected]>2020-12-03 22:42:29 -0500
commitc221eb3d62ccbd7f2a5203abd3e0eae8e9bf31e8 (patch)
tree10f984c905084eae140d7eb15eb81592f50d537f /grapher/Models/Charts
parentfix chart range not updating on disable (diff)
downloadrawaccel-c221eb3d62ccbd7f2a5203abd3e0eae8e9bf31e8.tar.xz
rawaccel-c221eb3d62ccbd7f2a5203abd3e0eae8e9bf31e8.zip
add changes from review
rename some vars prefer exceptions over assert refactor poll rate field usage in MouseWatcher
Diffstat (limited to 'grapher/Models/Charts')
-rw-r--r--grapher/Models/Charts/ChartXY.cs16
1 files changed, 12 insertions, 4 deletions
diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs
index 953065e..553ab3e 100644
--- a/grapher/Models/Charts/ChartXY.cs
+++ b/grapher/Models/Charts/ChartXY.cs
@@ -1,6 +1,6 @@
using grapher.Models.Mouse;
+using System;
using System.Collections;
-using System.Diagnostics;
using System.Windows.Forms.DataVisualization.Charting;
namespace grapher
@@ -222,20 +222,28 @@ namespace grapher
ChartX.Series[2].IsVisibleInLegend = true;
}
+ private void VerifyRange(double min, double max)
+ {
+ if (min > max)
+ {
+ throw new ArgumentException($"invalid chart range: ({min}, {max})");
+ }
+ }
+
public void SetMinMax(double min, double max)
{
- Debug.Assert(min <= max);
+ VerifyRange(min, max);
ChartX.ChartAreas[0].AxisY.Minimum = min * (1 - VerticalMargin);
ChartX.ChartAreas[0].AxisY.Maximum = max * (1 + VerticalMargin);
}
public void SetMinMaxXY(double minX, double maxX, double minY, double maxY)
{
- Debug.Assert(minX <= maxY);
+ VerifyRange(minX, maxX);
ChartX.ChartAreas[0].AxisY.Minimum = minX * (1 - VerticalMargin);
ChartX.ChartAreas[0].AxisY.Maximum = maxX * (1 + VerticalMargin);
- Debug.Assert(minX <= maxY);
+ VerifyRange(minY, maxY);
ChartX.ChartAreas[0].AxisY.Minimum = minY * (1 - VerticalMargin);
ChartX.ChartAreas[0].AxisY.Maximum = maxY * (1 + VerticalMargin);
}