1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-13 22:48:50 -05:00

Center constant data when fitting. (#154)

Co-authored-by: Yan Zaretskiy <yzaretskiy@stoneridgetechnology.com>
This commit is contained in:
Yan 2020-12-04 14:33:44 -05:00 committed by GitHub
parent 4af202a988
commit 9b5adca5f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2393,8 +2393,8 @@ void EndPlot() {
if (!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LockMax) && !ImNanOrInf(gp.ExtentsX.Max)) if (!ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_LockMax) && !ImNanOrInf(gp.ExtentsX.Max))
plot.XAxis.Range.Max = (gp.ExtentsX.Max); plot.XAxis.Range.Max = (gp.ExtentsX.Max);
if (ImAlmostEqual(plot.XAxis.Range.Max, plot.XAxis.Range.Min)) { if (ImAlmostEqual(plot.XAxis.Range.Max, plot.XAxis.Range.Min)) {
plot.XAxis.Range.Max += plot.XAxis.Range.Max * 1.01; plot.XAxis.Range.Max += 0.5;
plot.XAxis.Range.Min -= plot.XAxis.Range.Max * 1.01; plot.XAxis.Range.Min -= 0.5;
} }
plot.XAxis.Constrain(); plot.XAxis.Constrain();
if (axis_equal && !gp.FitY[0]) if (axis_equal && !gp.FitY[0])
@ -2410,8 +2410,8 @@ void EndPlot() {
if (!ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LockMax) && !ImNanOrInf(gp.ExtentsY[i].Max)) if (!ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LockMax) && !ImNanOrInf(gp.ExtentsY[i].Max))
plot.YAxis[i].Range.Max = (gp.ExtentsY[i].Max); plot.YAxis[i].Range.Max = (gp.ExtentsY[i].Max);
if (ImAlmostEqual(plot.YAxis[i].Range.Max, plot.YAxis[i].Range.Min)) { if (ImAlmostEqual(plot.YAxis[i].Range.Max, plot.YAxis[i].Range.Min)) {
plot.YAxis[i].Range.Max += plot.YAxis[i].Range.Max * 1.01; plot.YAxis[i].Range.Max += 0.5;
plot.YAxis[i].Range.Min -= plot.YAxis[i].Range.Max * 1.01; plot.YAxis[i].Range.Min -= 0.5;
} }
plot.YAxis[i].Constrain(); plot.YAxis[i].Constrain();
if (i == 0 && axis_equal && !gp.FitX) if (i == 0 && axis_equal && !gp.FitX)