diff --git a/Charts/Classes/Charts/PieRadarChartViewBase.swift b/Charts/Classes/Charts/PieRadarChartViewBase.swift index cdeb1ecf71..538c4ec1f4 100755 --- a/Charts/Classes/Charts/PieRadarChartViewBase.swift +++ b/Charts/Classes/Charts/PieRadarChartViewBase.swift @@ -13,7 +13,7 @@ import Foundation import CoreGraphics -import UIKit.UIGestureRecognizer +import UIKit /// Base class of PieChartView and RadarChartView. public class PieRadarChartViewBase: ChartViewBase @@ -753,6 +753,11 @@ public class PieRadarChartViewBase: ChartViewBase dataSetIndex = ChartUtils.closestDataSetIndex(valsAtIndex, value: Double(distance / (self as! RadarChartView).factor), axis: nil); } + if (dataSetIndex < 0) + { + return; + } + var h = ChartHighlight(xIndex: index, dataSetIndex: dataSetIndex); if (_lastHighlight !== nil && h == _lastHighlight) diff --git a/Charts/Classes/Data/ChartDataSet.swift b/Charts/Classes/Data/ChartDataSet.swift index 88cc5316e0..ef7ed3ef0e 100644 --- a/Charts/Classes/Data/ChartDataSet.swift +++ b/Charts/Classes/Data/ChartDataSet.swift @@ -105,17 +105,17 @@ public class ChartDataSet: NSObject _lastStart = start; _lastEnd = endValue; - _yMin = yVals[start].value; - _yMax = yVals[start].value; + _yMin = DBL_MAX; + _yMax = DBL_MIN; - for (var i = start + 1; i <= endValue; i++) + for (var i = start; i <= endValue; i++) { let e = _yVals[i]; - if (e.value < _yMin) + if (!e.value.isNaN && e.value < _yMin) { _yMin = e.value; } - if (e.value > _yMax) + if (!e.value.isNaN && e.value > _yMax) { _yMax = e.value; } diff --git a/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift b/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift index 8ef7c811d2..0f99c1ed3b 100644 --- a/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift +++ b/Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift @@ -54,6 +54,12 @@ public class ChartYAxisRendererRadarChart: ChartYAxisRenderer interval = floor(10 * intervalMagnitude); } + // 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) { @@ -64,6 +70,11 @@ public class ChartYAxisRendererRadarChart: ChartYAxisRenderer else { var first = ceil(Double(yMin) / interval) * interval; + if (first.isSignMinus) + { + first = -first; + } + var last = ChartUtils.nextUp(floor(Double(yMax) / interval) * interval); var f: Double; diff --git a/Charts/Classes/Renderers/RadarChartRenderer.swift b/Charts/Classes/Renderers/RadarChartRenderer.swift index 8bbc7508a0..c5eb216b3c 100644 --- a/Charts/Classes/Renderers/RadarChartRenderer.swift +++ b/Charts/Classes/Renderers/RadarChartRenderer.swift @@ -59,6 +59,8 @@ public class RadarChartRenderer: ChartDataRendererBase var entries = dataSet.yVals; var path = CGPathCreateMutable(); + + var hasMovedToPoint = false; for (var j = 0; j < entries.count; j++) { @@ -66,9 +68,15 @@ public class RadarChartRenderer: ChartDataRendererBase var p = ChartUtils.getPosition(center: center, dist: CGFloat(e.value - _chart.chartYMin) * factor, angle: sliceangle * CGFloat(j) + _chart.rotationAngle); - if (j == 0) + if (p.x.isNaN || p.y.isNaN) + { + continue + } + + if (!hasMovedToPoint) { CGPathMoveToPoint(path, nil, p.x, p.y); + hasMovedToPoint = true; } else { @@ -273,6 +281,11 @@ public class RadarChartRenderer: ChartDataRendererBase var p = ChartUtils.getPosition(center: center, dist: CGFloat(y) * factor, angle: sliceangle * CGFloat(j) + _chart.rotationAngle); + if (p.x.isNaN || p.y.isNaN) + { + continue; + } + _lineSegments[0] = CGPoint(x: p.x, y: 0.0) _lineSegments[1] = CGPoint(x: p.x, y: viewPortHandler.chartHeight) _lineSegments[2] = CGPoint(x: 0.0, y: p.y)