-
Notifications
You must be signed in to change notification settings - Fork 981
Description
signal.Data.Rotated = true;
myPlot.Axes.SetLimitsY(1000, 0);
The MinimumSpan rule does not work as expected because the Span property in the CoordinateRangeMutable class returns a negative value in the inverted state.
Expected Behavior
The span should be handled correctly regardless of axis inversion.
Current Behavior
The MinimumSpan rule in the MinimumSpan class uses:
if (YAxis.Range.Span < YSpan)
{
double yMin = YAxis.Range.Center - YSpan / 2;
double yMax = YAxis.Range.Center + YSpan / 2;
YAxis.Range.Set(yMin, yMax);
}
This fails when the axis is inverted, it overrides the axis limits, the user can not zoom in or out.
Proposed Fix
Modify the code in MinimumSpan class as follows to handle the inverted axis correctly:
if (YAxis.IsInverted())
{
if (Math.Abs(YAxis.Range.Span) < YSpan)
{
double yMin = YAxis.Range.Center - YSpan / 2;
double yMax = YAxis.Range.Center + YSpan / 2;
YAxis.Range.Set(yMax, yMin);
}
}
else
{
if (YAxis.Range.Span < YSpan)
{
double yMin = YAxis.Range.Center - YSpan / 2;
double yMax = YAxis.Range.Center + YSpan / 2;
YAxis.Range.Set(yMin, yMax);
}
}
However, I am not sure if this is the best approach, or if it would be better to address the issue by modifying the Span property in the CoordinateRangeMutable class.
Additional Considerations
The same issue applies to both X and Y axes, meaning fixes should be applied consistently to both dimensions.
The issue also affects the MaximumSpan rule, which should be adjusted similarly.
**ScottPlot Version: 5.053