diff --git a/apps/graph/graph/graph_controller.cpp b/apps/graph/graph/graph_controller.cpp index b08f9963b..a077fc0ef 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -61,7 +61,8 @@ void GraphController::interestingRanges(float * xm, float * xM, float * ym, floa float xMax = const_cast(this)->interactiveCurveViewRange()->xMax(); assert(functionStore()->numberOfActiveFunctions() > 0); if (displaysNonCartesianFunctions()) { - for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) { + const int functionsCount = functionStore()->numberOfActiveFunctions(); + for (int i = 0; i < functionsCount; i++) { ExpiringPointer f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i)); if (f->plotType() == CartesianFunction::PlotType::Cartesian) { continue; @@ -75,6 +76,10 @@ void GraphController::interestingRanges(float * xm, float * xM, float * ym, floa assert(!std::isnan(f->rangeStep())); interestingFunctionRange(f, tMin, tMax, f->rangeStep(), &resultxMin, &resultxMax, &resultyMin, &resultyMax); } + if (resultxMin > resultxMax) { + resultxMin = - Range1D::k_default; + resultxMax = Range1D::k_default; + } } else { resultxMin = xMin; resultxMax = xMax; @@ -96,6 +101,11 @@ void GraphController::interestingRanges(float * xm, float * xM, float * ym, floa double tMax = minFloat(f->tMax(), xMax); interestingFunctionRange(f, tMin, tMax, step, &resultxMin, &resultxMax, &resultyMin, &resultyMax); } + if (resultyMin > resultyMax) { + resultyMin = - Range1D::k_default; + resultyMax = Range1D::k_default; + } + *xm = resultxMin; *xM = resultxMax; *ym = resultyMin; diff --git a/apps/shared/range_1D.h b/apps/shared/range_1D.h index d732276f7..70a81b0d1 100644 --- a/apps/shared/range_1D.h +++ b/apps/shared/range_1D.h @@ -12,7 +12,8 @@ namespace Shared { class __attribute__((packed)) Range1D final { public: constexpr static float k_minFloat = 1E-4f; - Range1D(float min = -10.0f, float max = 10.0f) : + constexpr static float k_default = 10.0f; + Range1D(float min = -k_default, float max = k_default) : m_min(min), m_max(max) {}