diff --git a/Charts/Classes/Charts/RadarChartView.swift b/Charts/Classes/Charts/RadarChartView.swift index baa0bf532c..6a98b2c144 100644 --- a/Charts/Classes/Charts/RadarChartView.swift +++ b/Charts/Classes/Charts/RadarChartView.swift @@ -101,9 +101,9 @@ public class RadarChartView: PieRadarChartViewBase else if minLeft >= 0.0 { // We have positive values only, stay in the positive zone - _yAxis.axisMinimum = 0.0 + _yAxis.axisMinimum = 0.0 _yAxis.axisMaximum = max(0.0, !isnan(_yAxis.customAxisMax) ? _yAxis.customAxisMax : (maxLeft + topSpaceLeft)) - } + } else { // Stick the minimum to 0.0 or less, and maximum to 0.0 or more (startAtZero for negative/positive at the same time) diff --git a/Charts/Classes/Data/BarChartDataSet.swift b/Charts/Classes/Data/BarChartDataSet.swift index 3f78c84189..88e00cb315 100644 --- a/Charts/Classes/Data/BarChartDataSet.swift +++ b/Charts/Classes/Data/BarChartDataSet.swift @@ -95,11 +95,11 @@ public class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet { if vals.count > _stackSize { - _stackSize = vals.count + _stackSize = vals.count + } } } } - } internal override func calcMinMax(start start : Int, end: Int) { diff --git a/Charts/Classes/Renderers/ChartYAxisRenderer.swift b/Charts/Classes/Renderers/ChartYAxisRenderer.swift index d2ee98e4a7..09dc299567 100644 --- a/Charts/Classes/Renderers/ChartYAxisRenderer.swift +++ b/Charts/Classes/Renderers/ChartYAxisRenderer.swift @@ -107,41 +107,41 @@ public class ChartYAxisRenderer: ChartAxisRendererBase { // no forced count - // if the labels should only show min and max - if (_yAxis.isShowOnlyMinMaxEnabled) - { - _yAxis.entries = [yMin, yMax] - } - else - { - let first = ceil(Double(yMin) / interval) * interval - let last = ChartUtils.nextUp(floor(Double(yMax) / interval) * interval) - - var f: Double - var i: Int - var n = 0 - for (f = first; f <= last; f += interval) + // if the labels should only show min and max + if (_yAxis.isShowOnlyMinMaxEnabled) { - ++n + _yAxis.entries = [yMin, yMax] } - - if (_yAxis.entries.count < n) - { - // Ensure stops contains at least numStops elements. - _yAxis.entries = [Double](count: n, repeatedValue: 0.0) - } - else if (_yAxis.entries.count > n) - { - _yAxis.entries.removeRange(n..<_yAxis.entries.count) - } - - for (f = first, i = 0; i < n; f += interval, ++i) + else { - _yAxis.entries[i] = Double(f) + let first = ceil(Double(yMin) / interval) * interval + let last = ChartUtils.nextUp(floor(Double(yMax) / interval) * interval) + + var f: Double + var i: Int + var n = 0 + for (f = first; f <= last; f += interval) + { + ++n + } + + if (_yAxis.entries.count < n) + { + // Ensure stops contains at least numStops elements. + _yAxis.entries = [Double](count: n, repeatedValue: 0.0) + } + else if (_yAxis.entries.count > n) + { + _yAxis.entries.removeRange(n..<_yAxis.entries.count) + } + + for (f = first, i = 0; i < n; f += interval, ++i) + { + _yAxis.entries[i] = Double(f) + } } } } - } /// draws the y-axis labels to the screen public override func renderAxisLabels(context context: CGContext) diff --git a/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift b/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift index b1babccc51..e6eb1fe7f5 100644 --- a/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift +++ b/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift @@ -25,7 +25,7 @@ public class ChartYAxisRendererRadarChart: ChartYAxisRenderer _chart = chart } - + public override func computeAxis(yMin yMin: Double, yMax: Double) { computeAxisValues(min: yMin, max: yMax) @@ -83,61 +83,61 @@ public class ChartYAxisRendererRadarChart: ChartYAxisRenderer { // no forced count - // clean old values - if (_yAxis.entries.count > 0) - { - _yAxis.entries.removeAll(keepCapacity: false) - } - - // if the labels should only show min and max - if (_yAxis.isShowOnlyMinMaxEnabled) - { - _yAxis.entries = [Double]() - _yAxis.entries.append(yMin) - _yAxis.entries.append(yMax) - } - else - { + // clean old values + if (_yAxis.entries.count > 0) + { + _yAxis.entries.removeAll(keepCapacity: false) + } + + // if the labels should only show min and max + if (_yAxis.isShowOnlyMinMaxEnabled) + { + _yAxis.entries = [Double]() + _yAxis.entries.append(yMin) + _yAxis.entries.append(yMax) + } + else + { let rawCount = Double(yMin) / interval var first = rawCount < 0.0 ? floor(rawCount) * interval : ceil(rawCount) * interval; - + if (first < yMin && _yAxis.isStartAtZeroEnabled) { // Force the first label to be at the 0 (or smallest negative value) first = yMin } - if (first == 0.0) - { // Fix for IEEE negative zero case (Where value == -0.0, and 0.0 == -0.0) - first = 0.0 - } - - let last = ChartUtils.nextUp(floor(Double(yMax) / interval) * interval) - - var f: Double - var i: Int - var n = 0 - for (f = first; f <= last; f += interval) - { - ++n - } - - if (isnan(_yAxis.customAxisMax)) - { - n += 1 - } - - if (_yAxis.entries.count < n) - { - // Ensure stops contains at least numStops elements. - _yAxis.entries = [Double](count: n, repeatedValue: 0.0) - } - - for (f = first, i = 0; i < n; f += interval, ++i) - { - _yAxis.entries[i] = Double(f) + if (first == 0.0) + { // Fix for IEEE negative zero case (Where value == -0.0, and 0.0 == -0.0) + first = 0.0 + } + + let last = ChartUtils.nextUp(floor(Double(yMax) / interval) * interval) + + var f: Double + var i: Int + var n = 0 + for (f = first; f <= last; f += interval) + { + ++n + } + + if (isnan(_yAxis.customAxisMax)) + { + n += 1 + } + + if (_yAxis.entries.count < n) + { + // Ensure stops contains at least numStops elements. + _yAxis.entries = [Double](count: n, repeatedValue: 0.0) + } + + for (f = first, i = 0; i < n; f += interval, ++i) + { + _yAxis.entries[i] = Double(f) + } } } - } if !_yAxis.isStartAtZeroEnabled && _yAxis.entries[0] < yMin {