public void AxisAuto( double horizontalMargin = .1, double verticalMargin = .1, bool xExpandOnly = false, bool yExpandOnly = false, bool autoX = true, bool autoY = true ) { var oldLimits = new Config.AxisLimits2D(axes.ToArray()); var newLimits = new Config.AxisLimits2D(); foreach (var plottable in plottables) { Config.AxisLimits2D plottableLimits = plottable.GetLimits(); if (autoX && !yExpandOnly) { newLimits.ExpandX(plottableLimits); } if (autoY && !xExpandOnly) { newLimits.ExpandY(plottableLimits); } } newLimits.MakeRational(); if (axes.equalAxes) { var xUnitsPerPixel = newLimits.xSpan / (dataSize.Width * (1 - horizontalMargin)); var yUnitsPerPixel = newLimits.ySpan / (dataSize.Height * (1 - verticalMargin)); axes.Set(newLimits); if (yUnitsPerPixel > xUnitsPerPixel) { axes.Zoom((1 - horizontalMargin) * xUnitsPerPixel / yUnitsPerPixel, 1 - verticalMargin); } else { axes.Zoom(1 - horizontalMargin, (1 - verticalMargin) * yUnitsPerPixel / xUnitsPerPixel); } return; } if (xExpandOnly) { oldLimits.ExpandX(newLimits); axes.Set(oldLimits.x1, oldLimits.x2, null, null); axes.Zoom(1 - horizontalMargin, 1); } if (yExpandOnly) { oldLimits.ExpandY(newLimits); axes.Set(null, null, oldLimits.y1, oldLimits.y2); axes.Zoom(1, 1 - verticalMargin); } if ((!xExpandOnly) && (!yExpandOnly)) { axes.Set(newLimits); axes.Zoom(1 - horizontalMargin, 1 - verticalMargin); } }
public void AxisAuto( double horizontalMargin = .1, double verticalMargin = .1, bool xExpandOnly = false, bool yExpandOnly = false, bool autoX = true, bool autoY = true ) { var oldLimits = new Config.AxisLimits2D(axes.ToArray()); var newLimits = new Config.AxisLimits2D(); foreach (var plottable in plottables) { Config.AxisLimits2D plottableLimits = plottable.GetLimits(); if (autoX && !yExpandOnly) { newLimits.ExpandX(plottableLimits); } if (autoY && !xExpandOnly) { newLimits.ExpandY(plottableLimits); } } newLimits.MakeRational(); if (xExpandOnly) { oldLimits.ExpandX(newLimits); axes.Set(oldLimits.x1, oldLimits.x2, null, null); axes.Zoom(1 - horizontalMargin, 1); } if (yExpandOnly) { oldLimits.ExpandY(newLimits); axes.Set(null, null, oldLimits.y1, oldLimits.y2); axes.Zoom(1, 1 - verticalMargin); } if ((!xExpandOnly) && (!yExpandOnly)) { axes.Set(newLimits); axes.Zoom(1 - horizontalMargin, 1 - verticalMargin); } }