diff --git a/Source/Charts/Components/YAxis.swift b/Source/Charts/Components/YAxis.swift index 0edf78382c..44b07f67c1 100644 --- a/Source/Charts/Components/YAxis.swift +++ b/Source/Charts/Components/YAxis.swift @@ -150,8 +150,19 @@ open class YAxis: AxisBase var min = _customAxisMin ? _axisMinimum : dataMin var max = _customAxisMax ? _axisMaximum : dataMax - min = max < min ? max : min - max = min > max ? min : max + if min > max { + if _customAxisMax && _customAxisMin { + //both max and min are manullay setted + min = max < min ? max : min + max = min > max ? min : max + } else if _customAxisMax && !_customAxisMin { + min = max - 1 + } else if !_customAxisMax && _customAxisMin { + max = min + 1 + } + } + + // temporary range (before calculations) let range = abs(max - min)