diff --git a/Charts/Classes/Animation/ChartAnimationEasing.swift b/Charts/Classes/Animation/ChartAnimationEasing.swift index 4f89ef0629..b6719ca4d9 100644 --- a/Charts/Classes/Animation/ChartAnimationEasing.swift +++ b/Charts/Classes/Animation/ChartAnimationEasing.swift @@ -331,7 +331,11 @@ internal struct EasingFunctions return CGFloat( -0.5 * (pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p)) ) } position -= 1.0 - return CGFloat( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p) * 0.5 + 1.0 ) + + let tempPOW = pow(2.0, -10.0 * position) + let tempSIN = sin((position * duration - s) * (2.0 * M_PI) / p) + + return CGFloat( tempPOW * tempSIN * 0.5 + 1.0 ) } internal static let EaseInBack = { (elapsed: TimeInterval, duration: TimeInterval) -> CGFloat in diff --git a/Charts/Classes/Charts/BarLineChartViewBase.swift b/Charts/Classes/Charts/BarLineChartViewBase.swift index 1c599ba5d8..1852e81116 100644 --- a/Charts/Classes/Charts/BarLineChartViewBase.swift +++ b/Charts/Classes/Charts/BarLineChartViewBase.swift @@ -40,7 +40,7 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar /// the color for the background of the chart-drawing area (everything behind the grid lines). public var gridBackgroundColor = NSUIColor(red: 240/255.0, green: 240/255.0, blue: 240/255.0, alpha: 1.0) - public var borderColor = NSUIColor.black() + public var borderColor = NSUIColor.black public var borderLineWidth: CGFloat = 1.0 /// flag indicating if the grid background should be drawn or not @@ -216,7 +216,7 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar // make sure the graph values and grid cannot be drawn outside the content-rect context.saveGState() - context.clipTo(_viewPortHandler.contentRect) + context.clip(to: _viewPortHandler.contentRect) _xAxisRenderer?.renderGridLines(context: context) _leftYAxisRenderer?.renderGridLines(context: context) @@ -248,7 +248,7 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar renderer!.drawExtras(context: context) context.saveGState() - context.clipTo(_viewPortHandler.contentRect) + context.clip(to: _viewPortHandler.contentRect) if !_xAxis.drawLimitLinesBehindDataEnabled { @@ -325,7 +325,7 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar // calculate / set x-axis range _xAxis._axisMaximum = Double((_data?.xVals.count ?? 0) - 1) - _xAxis.axisRange = .abs(_xAxis._axisMaximum - _xAxis._axisMinimum); + _xAxis.axisRange = abs(_xAxis._axisMaximum - _xAxis._axisMinimum); // calculate axis range (min / max) according to provided data _leftAxis.calculate(min: _data?.getYMin(.left) ?? 0.0, max: _data?.getYMax(.left) ?? 0.0) @@ -715,10 +715,10 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar let scaleY = canZoomMoreY ? recognizer.nsuiScale : 1.0 var matrix = CGAffineTransform(translationX: location.x, y: location.y) - matrix = matrix.scaleBy(x: scaleX, y: scaleY) - matrix = matrix.translateBy(x: -location.x, y: -location.y) + matrix = matrix.scaledBy(x: scaleX, y: scaleY) + matrix = matrix.translatedBy(x: -location.x, y: -location.y) - matrix = _viewPortHandler.touchMatrix.concat(matrix) + matrix = _viewPortHandler.touchMatrix.concatenating(matrix) _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: true) @@ -858,7 +858,7 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar let originalMatrix = _viewPortHandler.touchMatrix var matrix = CGAffineTransform(translationX: translation.x, y: translation.y) - matrix = originalMatrix.concat(matrix) + matrix = originalMatrix.concatenating(matrix) matrix = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: true) diff --git a/Charts/Classes/Charts/ChartViewBase.swift b/Charts/Classes/Charts/ChartViewBase.swift index af68c478de..cb9ceac19b 100755 --- a/Charts/Classes/Charts/ChartViewBase.swift +++ b/Charts/Classes/Charts/ChartViewBase.swift @@ -70,7 +70,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate public var descriptionFont: NSUIFont? = NSUIFont(name: "HelveticaNeue", size: 9.0) /// Text color used for drawing the description text - public var descriptionTextColor: NSUIColor? = NSUIColor.black() + public var descriptionTextColor: NSUIColor? = NSUIColor.black /// Text align used for drawing the description text public var descriptionTextAlign: NSTextAlignment = NSTextAlignment.right @@ -157,7 +157,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate super.init(frame: frame) #if os(iOS) - self.backgroundColor = NSUIColor.clear() + self.backgroundColor = NSUIColor.clear #endif initialize() } @@ -358,7 +358,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate // 23 is the smallest recommended font size on the TV font = NSUIFont.systemFont(ofSize: 23, weight: UIFontWeightMedium) #else - font = NSUIFont.systemFont(ofSize: NSUIFont.systemFontSize()) + font = NSUIFont.systemFont(ofSize: NSUIFont.systemFontSize) #endif } @@ -813,7 +813,7 @@ public class ChartViewBase: NSUIView, ChartDataProvider, ChartAnimatorDelegate if (isOpaque || !transparent) { // Background color may be partially transparent, we must fill with white if we want to output an opaque image - context.setFillColor(NSUIColor.white().cgColor) + context.setFillColor(NSUIColor.white.cgColor) context.fill(rect) if (self.backgroundColor !== nil) diff --git a/Charts/Classes/Charts/PieChartView.swift b/Charts/Classes/Charts/PieChartView.swift index fa0cdc671a..7a9d4e7247 100755 --- a/Charts/Classes/Charts/PieChartView.swift +++ b/Charts/Classes/Charts/PieChartView.swift @@ -35,7 +35,7 @@ public class PieChartView: PieRadarChartViewBase /// if true, the hole inside the chart will be drawn private var _drawHoleEnabled = true - private var _holeColor: NSUIColor? = NSUIColor.white() + private var _holeColor: NSUIColor? = NSUIColor.white /// if true, the hole will see-through to the inner tips of the slices private var _drawSlicesUnderHoleEnabled = false @@ -44,7 +44,7 @@ public class PieChartView: PieRadarChartViewBase private var _usePercentValuesEnabled = false /// variable for the text that is drawn in the center of the pie-chart - private var _centerAttributedText: AttributedString? + private var _centerAttributedText: NSAttributedString? /// indicates the size of the hole in the center of the piechart /// @@ -358,13 +358,13 @@ public class PieChartView: PieRadarChartViewBase } else { - let paragraphStyle = NSParagraphStyle.default().mutableCopy() as! NSMutableParagraphStyle + let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle paragraphStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail paragraphStyle.alignment = .center attrString = NSMutableAttributedString(string: newValue!) attrString?.setAttributes([ - NSForegroundColorAttributeName: NSUIColor.black(), + NSForegroundColorAttributeName: NSUIColor.black, NSFontAttributeName: NSUIFont.systemFont(ofSize: 12.0), NSParagraphStyleAttributeName: paragraphStyle ], range: NSMakeRange(0, attrString!.length)) @@ -374,7 +374,7 @@ public class PieChartView: PieRadarChartViewBase } /// the text that is displayed in the center of the pie-chart - public var centerAttributedText: AttributedString? + public var centerAttributedText: NSAttributedString? { get { diff --git a/Charts/Classes/Components/ChartAxisBase.swift b/Charts/Classes/Components/ChartAxisBase.swift index 74d436a0d0..ba698ccd64 100644 --- a/Charts/Classes/Components/ChartAxisBase.swift +++ b/Charts/Classes/Components/ChartAxisBase.swift @@ -19,14 +19,14 @@ import CoreGraphics public class ChartAxisBase: ChartComponentBase { public var labelFont = NSUIFont.systemFont(ofSize: 10.0) - public var labelTextColor = NSUIColor.black() + public var labelTextColor = NSUIColor.black - public var axisLineColor = NSUIColor.gray() + public var axisLineColor = NSUIColor.gray public var axisLineWidth = CGFloat(0.5) public var axisLineDashPhase = CGFloat(0.0) public var axisLineDashLengths: [CGFloat]! - public var gridColor = NSUIColor.gray().withAlphaComponent(0.9) + public var gridColor = NSUIColor.gray.withAlphaComponent(0.9) public var gridLineWidth = CGFloat(0.5) public var gridLineDashPhase = CGFloat(0.0) public var gridLineDashLengths: [CGFloat]! diff --git a/Charts/Classes/Components/ChartLegend.swift b/Charts/Classes/Components/ChartLegend.swift index 1f1fac1f68..cc0058f768 100644 --- a/Charts/Classes/Components/ChartLegend.swift +++ b/Charts/Classes/Components/ChartLegend.swift @@ -194,8 +194,7 @@ public class ChartLegend: ChartComponentBase public var direction: Direction = Direction.leftToRight public var font: NSUIFont = NSUIFont.systemFont(ofSize: 10.0) - public var textColor = NSUIColor.black() - + public var textColor = NSUIColor.black public var form = Form.square public var formSize = CGFloat(8.0) public var formLineWidth = CGFloat(1.5) diff --git a/Charts/Classes/Components/ChartLimitLine.swift b/Charts/Classes/Components/ChartLimitLine.swift index d80b73c678..5927c8aecb 100644 --- a/Charts/Classes/Components/ChartLimitLine.swift +++ b/Charts/Classes/Components/ChartLimitLine.swift @@ -36,7 +36,7 @@ public class ChartLimitLine: ChartComponentBase public var lineColor = NSUIColor(red: 237.0/255.0, green: 91.0/255.0, blue: 91.0/255.0, alpha: 1.0) public var lineDashPhase = CGFloat(0.0) public var lineDashLengths: [CGFloat]? - public var valueTextColor = NSUIColor.black() + public var valueTextColor = NSUIColor.black public var valueFont = NSUIFont.systemFont(ofSize: 13.0) public var label = "" public var drawLabelEnabled = true diff --git a/Charts/Classes/Components/ChartYAxis.swift b/Charts/Classes/Components/ChartYAxis.swift index f43833521a..cf16a33f5c 100644 --- a/Charts/Classes/Components/ChartYAxis.swift +++ b/Charts/Classes/Components/ChartYAxis.swift @@ -83,7 +83,7 @@ public class ChartYAxis: ChartAxisBase public var drawZeroLineEnabled = false /// Color of the zero line - public var zeroLineColor: NSUIColor? = NSUIColor.gray() + public var zeroLineColor: NSUIColor? = NSUIColor.gray /// Width of the zero line public var zeroLineWidth: CGFloat = 1.0 diff --git a/Charts/Classes/Data/Implementations/ChartBaseDataSet.swift b/Charts/Classes/Data/Implementations/ChartBaseDataSet.swift index 88e55b83ec..b5d8ffb679 100644 --- a/Charts/Classes/Data/Implementations/ChartBaseDataSet.swift +++ b/Charts/Classes/Data/Implementations/ChartBaseDataSet.swift @@ -24,7 +24,7 @@ public class ChartBaseDataSet: NSObject, IChartDataSet // default color colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0)) - valueColors.append(NSUIColor.black()) + valueColors.append(NSUIColor.black) } public init(label: String?) @@ -33,7 +33,7 @@ public class ChartBaseDataSet: NSObject, IChartDataSet // default color colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0)) - valueColors.append(NSUIColor.black()) + valueColors.append(NSUIColor.black) self.label = label } diff --git a/Charts/Classes/Data/Implementations/Standard/BarChartDataSet.swift b/Charts/Classes/Data/Implementations/Standard/BarChartDataSet.swift index 06eda045d1..8149364b52 100644 --- a/Charts/Classes/Data/Implementations/Standard/BarChartDataSet.swift +++ b/Charts/Classes/Data/Implementations/Standard/BarChartDataSet.swift @@ -19,7 +19,7 @@ public class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, IBarChartD { private func initialize() { - self.highlightColor = NSUIColor.black() + self.highlightColor = NSUIColor.black self.calcStackSize(yVals as! [BarChartDataEntry]) self.calcEntryCountIncludingStacks(yVals as! [BarChartDataEntry]) @@ -182,7 +182,7 @@ public class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, IBarChartD public var barBorderWidth : CGFloat = 0.0 /// the color drawing borders around the bars. - public var barBorderColor = NSUIColor.black() + public var barBorderColor = NSUIColor.black /// the alpha value (transparency) that is used for drawing the highlight indicator bar. min = 0.0 (fully transparent), max = 1.0 (fully opaque) public var highlightAlpha = CGFloat(120.0 / 255.0) diff --git a/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift b/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift index 2a210064ae..98a8482fdb 100644 --- a/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift +++ b/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift @@ -143,7 +143,7 @@ public class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet public var drawCirclesEnabled = true /// The color of the inner circle (the circle-hole). - public var circleHoleColor: NSUIColor? = NSUIColor.white() + public var circleHoleColor: NSUIColor? = NSUIColor.white /// True if drawing circles for this DataSet is enabled, false if not public var drawCircleHoleEnabled = true diff --git a/Charts/Classes/Data/Implementations/Standard/PieChartDataSet.swift b/Charts/Classes/Data/Implementations/Standard/PieChartDataSet.swift index 70623b2a50..d84f047246 100644 --- a/Charts/Classes/Data/Implementations/Standard/PieChartDataSet.swift +++ b/Charts/Classes/Data/Implementations/Standard/PieChartDataSet.swift @@ -26,7 +26,7 @@ public class PieChartDataSet: ChartDataSet, IPieChartDataSet private func initialize() { - self.valueTextColor = NSUIColor.white() + self.valueTextColor = NSUIColor.white self.valueFont = NSUIFont.systemFont(ofSize: 13.0) } @@ -77,7 +77,7 @@ public class PieChartDataSet: ChartDataSet, IPieChartDataSet public var yValuePosition: ValuePosition = .insideSlice /// When valuePosition is OutsideSlice, indicates line color - public var valueLineColor: NSUIColor? = NSUIColor.black() + public var valueLineColor: NSUIColor? = NSUIColor.black /// When valuePosition is OutsideSlice, indicates line width public var valueLineWidth: CGFloat = 1.0 diff --git a/Charts/Classes/Data/Implementations/Standard/RadarChartDataSet.swift b/Charts/Classes/Data/Implementations/Standard/RadarChartDataSet.swift index 89ccdf08de..32b976054a 100644 --- a/Charts/Classes/Data/Implementations/Standard/RadarChartDataSet.swift +++ b/Charts/Classes/Data/Implementations/Standard/RadarChartDataSet.swift @@ -43,7 +43,7 @@ public class RadarChartDataSet: LineRadarChartDataSet, IRadarChartDataSet /// **default**: false public var drawHighlightCircleEnabled: Bool = false - public var highlightCircleFillColor: NSUIColor? = NSUIColor.white() + public var highlightCircleFillColor: NSUIColor? = NSUIColor.white /// The stroke color for highlight circle. /// If `nil`, the color of the dataset is taken. diff --git a/Charts/Classes/Jobs/AnimatedZoomViewJob.swift b/Charts/Classes/Jobs/AnimatedZoomViewJob.swift index 57d813e13e..115acac503 100644 --- a/Charts/Classes/Jobs/AnimatedZoomViewJob.swift +++ b/Charts/Classes/Jobs/AnimatedZoomViewJob.swift @@ -77,10 +77,9 @@ public class AnimatedZoomChartViewJob: AnimatedViewPortJob let valsInView = CGFloat(yAxis?.axisRange ?? 0.0) / viewPortHandler.scaleY let xsInView = CGFloat(xValCount) / viewPortHandler.scaleX - var pt = CGPoint( - x: zoomOriginX + ((zoomCenterX - xsInView / 2.0) - zoomOriginX) * phase, - y: zoomOriginY + ((zoomCenterY + valsInView / 2.0) - zoomOriginY) * phase - ) + let x = zoomOriginX + ((zoomCenterX - xsInView / 2.0) - zoomOriginX) * phase + let y = zoomOriginY + ((zoomCenterY + valsInView / 2.0) - zoomOriginY) * phase + var pt = CGPoint(x: x, y: y) transformer.pointValueToPixel(&pt) diff --git a/Charts/Classes/Renderers/BarChartRenderer.swift b/Charts/Classes/Renderers/BarChartRenderer.swift index e83f07b8e1..6af999cd3f 100644 --- a/Charts/Classes/Renderers/BarChartRenderer.swift +++ b/Charts/Classes/Renderers/BarChartRenderer.swift @@ -557,7 +557,10 @@ public class BarChartRenderer: ChartDataRendererBase context.saveGState() let pixelToValueMatrix = trans.pixelToValueMatrix - let xToYRel = abs(sqrt(pixelToValueMatrix.b * pixelToValueMatrix.b + pixelToValueMatrix.d * pixelToValueMatrix.d) / sqrt(pixelToValueMatrix.a * pixelToValueMatrix.a + pixelToValueMatrix.c * pixelToValueMatrix.c)) + let sqrtAC = sqrt(pixelToValueMatrix.a * pixelToValueMatrix.a + pixelToValueMatrix.c * pixelToValueMatrix.c) + let sqrtBD = sqrt(pixelToValueMatrix.b * pixelToValueMatrix.b + pixelToValueMatrix.d * pixelToValueMatrix.d) + + let xToYRel = abs(sqrtBD / sqrtAC) let arrowWidth = set.barSpace / 2.0 let arrowHeight = arrowWidth * xToYRel diff --git a/Charts/Classes/Renderers/BubbleChartRenderer.swift b/Charts/Classes/Renderers/BubbleChartRenderer.swift index 282900d373..4265270687 100644 --- a/Charts/Classes/Renderers/BubbleChartRenderer.swift +++ b/Charts/Classes/Renderers/BubbleChartRenderer.swift @@ -103,7 +103,7 @@ public class BubbleChartRenderer: ChartDataRendererBase _pointBuffer.x = CGFloat(entry.xIndex - minx) * phaseX + CGFloat(minx) _pointBuffer.y = CGFloat(entry.value) * phaseY - _pointBuffer = _pointBuffer.apply(transform: valueToPixelMatrix) + _pointBuffer = _pointBuffer.applying(valueToPixelMatrix) let shapeSize = getShapeSize(entrySize: entry.size, maxSize: dataSet.maxSize, reference: referenceSize, normalizeSize: normalizeSize) let shapeHalf = shapeSize / 2.0 @@ -190,7 +190,7 @@ public class BubbleChartRenderer: ChartDataRendererBase pt.x = CGFloat(e.xIndex - minx) * phaseX + CGFloat(minx) pt.y = CGFloat(e.value) * phaseY - pt = pt.apply(transform: valueToPixelMatrix) + pt = pt.applying(valueToPixelMatrix) if (!viewPortHandler.isInBoundsRight(pt.x)) { diff --git a/Charts/Classes/Renderers/CandleStickChartRenderer.swift b/Charts/Classes/Renderers/CandleStickChartRenderer.swift index b3fcf796d5..25e1e5940b 100644 --- a/Charts/Classes/Renderers/CandleStickChartRenderer.swift +++ b/Charts/Classes/Renderers/CandleStickChartRenderer.swift @@ -292,7 +292,7 @@ public class CandleStickChartRenderer: LineScatterCandleRadarChartRenderer pt.x = CGFloat(e.xIndex) pt.y = CGFloat(e.high) * phaseY - pt = pt.apply(transform: valueToPixelMatrix) + pt = pt.applying(valueToPixelMatrix) if (!viewPortHandler.isInBoundsRight(pt.x)) { diff --git a/Charts/Classes/Renderers/ChartLegendRenderer.swift b/Charts/Classes/Renderers/ChartLegendRenderer.swift index b7717b8808..5b25863e69 100755 --- a/Charts/Classes/Renderers/ChartLegendRenderer.swift +++ b/Charts/Classes/Renderers/ChartLegendRenderer.swift @@ -400,7 +400,7 @@ public class ChartLegendRenderer: ChartRendererBase /// Draws the Legend-form at the given position with the color at the given index. public func drawForm(context: CGContext, x: CGFloat, y: CGFloat, colorIndex: Int, legend: ChartLegend) { - guard let formColor = legend.colors[colorIndex] where formColor != NSUIColor.clear() else { + guard let formColor = legend.colors[colorIndex] where formColor != NSUIColor.clear else { return } diff --git a/Charts/Classes/Renderers/ChartXAxisRenderer.swift b/Charts/Classes/Renderers/ChartXAxisRenderer.swift index 37e85af644..112161d793 100644 --- a/Charts/Classes/Renderers/ChartXAxisRenderer.swift +++ b/Charts/Classes/Renderers/ChartXAxisRenderer.swift @@ -148,7 +148,7 @@ public class ChartXAxisRenderer: ChartAxisRendererBase { guard let xAxis = xAxis else { return } - let paraStyle = NSParagraphStyle.default().mutableCopy() as! NSMutableParagraphStyle + let paraStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle paraStyle.alignment = .center let labelAttrs = [NSFontAttributeName: xAxis.labelFont, @@ -177,7 +177,7 @@ public class ChartXAxisRenderer: ChartAxisRendererBase position.x = CGFloat(i) position.y = 0.0 - position = position.apply(transform: valueToPixelMatrix) + position = position.applying(valueToPixelMatrix) if (viewPortHandler.isInBoundsX(position.x)) { @@ -251,7 +251,7 @@ public class ChartXAxisRenderer: ChartAxisRendererBase { position.x = CGFloat(i) position.y = 0.0 - position = position.apply(transform: valueToPixelMatrix) + position = position.applying(valueToPixelMatrix) if (position.x >= viewPortHandler.offsetLeft && position.x <= viewPortHandler.chartWidth) @@ -295,7 +295,7 @@ public class ChartXAxisRenderer: ChartAxisRendererBase position.x = CGFloat(l.limit) position.y = 0.0 - position = position.apply(transform: trans) + position = position.applying(trans) renderLimitLineLine(context: context, limitLine: l, position: position) renderLimitLineLabel(context: context, limitLine: l, position: position, yOffset: 2.0 + l.yOffset) diff --git a/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift b/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift index 99848ddb93..fbe4d98803 100644 --- a/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift +++ b/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift @@ -38,7 +38,7 @@ public class ChartXAxisRendererBarChart: ChartXAxisRenderer barData = chart?.data as? BarChartData else { return } - let paraStyle = NSParagraphStyle.default().mutableCopy() as! NSMutableParagraphStyle + let paraStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle paraStyle.alignment = .center let labelAttrs = [NSFontAttributeName: xAxis.labelFont, @@ -76,7 +76,7 @@ public class ChartXAxisRendererBarChart: ChartXAxisRenderer position.x += (CGFloat(step) - 1.0) / 2.0 } - position = position.apply(transform: valueToPixelMatrix) + position = position.applying(valueToPixelMatrix) if (viewPortHandler.isInBoundsX(position.x)) { @@ -148,7 +148,7 @@ public class ChartXAxisRendererBarChart: ChartXAxisRenderer { position.x = CGFloat(i * step) + CGFloat(i) * barData.groupSpace - 0.5 position.y = 0.0 - position = position.apply(transform: valueToPixelMatrix) + position = position.applying(valueToPixelMatrix) if (viewPortHandler.isInBoundsX(position.x)) { diff --git a/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift b/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift index a382c1bd57..f3744e25f4 100644 --- a/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift +++ b/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift @@ -267,7 +267,7 @@ public class ChartXAxisRendererHorizontalBarChart: ChartXAxisRendererBarChart position.x = 0.0 position.y = CGFloat(l.limit) - position = position.apply(transform: trans) + position = position.applying(trans) _limitLineSegmentsBuffer[0].x = viewPortHandler.contentLeft _limitLineSegmentsBuffer[0].y = position.y diff --git a/Charts/Classes/Renderers/ChartYAxisRenderer.swift b/Charts/Classes/Renderers/ChartYAxisRenderer.swift index 1080ef3c47..7a1cbbac39 100644 --- a/Charts/Classes/Renderers/ChartYAxisRenderer.swift +++ b/Charts/Classes/Renderers/ChartYAxisRenderer.swift @@ -291,7 +291,7 @@ public class ChartYAxisRenderer: ChartAxisRendererBase pt.x = 0 pt.y = CGFloat(yAxis.entries[i]) - pt = pt.apply(transform: valueToPixelMatrix) + pt = pt.applying(valueToPixelMatrix) pt.x = fixedPosition pt.y += offset @@ -338,7 +338,7 @@ public class ChartYAxisRenderer: ChartAxisRendererBase { position.x = 0.0 position.y = CGFloat(yAxis.entries[i]) - position = position.apply(transform: valueToPixelMatrix) + position = position.applying(valueToPixelMatrix) _gridLineBuffer[0].x = viewPortHandler.contentLeft _gridLineBuffer[0].y = position.y @@ -429,7 +429,7 @@ public class ChartYAxisRenderer: ChartAxisRendererBase position.x = 0.0 position.y = CGFloat(l.limit) - position = position.apply(transform: trans) + position = position.applying(trans) _limitLineSegmentsBuffer[0].x = viewPortHandler.contentLeft _limitLineSegmentsBuffer[0].y = position.y diff --git a/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift b/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift index 424c819f69..de2625559b 100644 --- a/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift +++ b/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift @@ -268,7 +268,7 @@ public class ChartYAxisRendererHorizontalBarChart: ChartYAxisRenderer position.x = CGFloat(l.limit) position.y = 0.0 - position = position.apply(transform: trans) + position = position.applying(trans) _limitLineSegmentsBuffer[0].x = position.x _limitLineSegmentsBuffer[0].y = viewPortHandler.contentTop diff --git a/Charts/Classes/Renderers/LineChartRenderer.swift b/Charts/Classes/Renderers/LineChartRenderer.swift index d04b478c9e..b0541a2719 100644 --- a/Charts/Classes/Renderers/LineChartRenderer.swift +++ b/Charts/Classes/Renderers/LineChartRenderer.swift @@ -272,8 +272,8 @@ public class LineChartRenderer: LineRadarChartRenderer var pt1 = CGPoint(x: CGFloat(xTo), y: fillMin) var pt2 = CGPoint(x: CGFloat(xFrom), y: fillMin) - pt1 = pt1.apply(transform: matrix) - pt2 = pt2.apply(transform: matrix) + pt1 = pt1.applying(matrix) + pt2 = pt2.applying(matrix) spline.addLineTo(nil, x: pt1.x, y: pt1.y) spline.addLineTo(nil, x: pt2.x, y: pt2.y) @@ -372,7 +372,7 @@ public class LineChartRenderer: LineRadarChartRenderer for i in 0..<_lineSegments.count { - _lineSegments[i] = _lineSegments[i].apply(transform: valueToPixelMatrix) + _lineSegments[i] = _lineSegments[i].applying(valueToPixelMatrix) } if (!viewPortHandler.isInBoundsRight(_lineSegments[0].x)) @@ -421,7 +421,7 @@ public class LineChartRenderer: LineRadarChartRenderer _lineSegments[j] = CGPoint( x: CGFloat(e1.xIndex), y: CGFloat(e1.value) * phaseY - ).apply(transform: valueToPixelMatrix) + ).applying(valueToPixelMatrix) j += 1 if drawSteppedEnabled @@ -429,20 +429,20 @@ public class LineChartRenderer: LineRadarChartRenderer _lineSegments[j] = CGPoint( x: CGFloat(e2.xIndex), y: CGFloat(e1.value) * phaseY - ).apply(transform: valueToPixelMatrix) + ).applying(valueToPixelMatrix) j += 1 _lineSegments[j] = CGPoint( x: CGFloat(e2.xIndex), y: CGFloat(e1.value) * phaseY - ).apply(transform: valueToPixelMatrix) + ).applying(valueToPixelMatrix) j += 1 } _lineSegments[j] = CGPoint( x: CGFloat(e2.xIndex), y: CGFloat(e2.value) * phaseY - ).apply(transform: valueToPixelMatrix) + ).applying(valueToPixelMatrix) j += 1 } @@ -592,7 +592,7 @@ public class LineChartRenderer: LineRadarChartRenderer pt.x = CGFloat(e.xIndex) pt.y = CGFloat(e.value) * phaseY - pt = pt.apply(transform: valueToPixelMatrix) + pt = pt.applying(valueToPixelMatrix) if (!viewPortHandler.isInBoundsRight(pt.x)) { @@ -663,7 +663,7 @@ public class LineChartRenderer: LineRadarChartRenderer circleHoleRadius > 0.0 let drawTransparentCircleHole = drawCircleHole && (dataSet.circleHoleColor == nil || - dataSet.circleHoleColor == NSUIColor.clear()) + dataSet.circleHoleColor == NSUIColor.clear) guard let entryFrom = dataSet.entryForXIndex(self.minX < 0 ? 0 : self.minX, rounding: .down), @@ -685,7 +685,7 @@ public class LineChartRenderer: LineRadarChartRenderer pt.x = CGFloat(e.xIndex) pt.y = CGFloat(e.value) * phaseY - pt = pt.apply(transform: valueToPixelMatrix) + pt = pt.applying(valueToPixelMatrix) if (!viewPortHandler.isInBoundsRight(pt.x)) { diff --git a/Charts/Classes/Renderers/PieChartRenderer.swift b/Charts/Classes/Renderers/PieChartRenderer.swift index 5fd1e984cf..ce496b4d09 100755 --- a/Charts/Classes/Renderers/PieChartRenderer.swift +++ b/Charts/Classes/Renderers/PieChartRenderer.swift @@ -531,7 +531,7 @@ public class PieChartRenderer: ChartDataRendererBase if let holeColor = chart.holeColor { - if holeColor != NSUIColor.clear() + if holeColor != NSUIColor.clear { // draw the hole-circle context.setFillColor(chart.holeColor!.cgColor) @@ -542,7 +542,7 @@ public class PieChartRenderer: ChartDataRendererBase // only draw the circle if it can be seen (not covered by the hole) if let transparentCircleColor = chart.transparentCircleColor { - if transparentCircleColor != NSUIColor.clear() && + if transparentCircleColor != NSUIColor.clear && chart.transparentCircleRadiusPercent > chart.holeRadiusPercent { let alpha = animator.phaseX * animator.phaseY diff --git a/Charts/Classes/Renderers/ScatterChartRenderer.swift b/Charts/Classes/Renderers/ScatterChartRenderer.swift index bfd43c16a2..2e20ca7744 100644 --- a/Charts/Classes/Renderers/ScatterChartRenderer.swift +++ b/Charts/Classes/Renderers/ScatterChartRenderer.swift @@ -87,7 +87,7 @@ public class ScatterChartRenderer: LineScatterCandleRadarChartRenderer point.x = CGFloat(e.xIndex) point.y = CGFloat(e.value) * phaseY - point = point.apply(transform: valueToPixelMatrix); + point = point.applying(valueToPixelMatrix); if (!viewPortHandler.isInBoundsRight(point.x)) { @@ -248,7 +248,7 @@ public class ScatterChartRenderer: LineScatterCandleRadarChartRenderer // transform the provided custom path context.saveGState() - context.translate(x: point.x, y: point.y) + context.translateBy(x: point.x, y: point.y) context.beginPath() context.addPath(customShape!) @@ -306,7 +306,7 @@ public class ScatterChartRenderer: LineScatterCandleRadarChartRenderer pt.x = CGFloat(e.xIndex) pt.y = CGFloat(e.value) * phaseY - pt = pt.apply(transform: valueToPixelMatrix) + pt = pt.applying(valueToPixelMatrix) if (!viewPortHandler.isInBoundsRight(pt.x)) { diff --git a/Charts/Classes/Utils/ChartColorTemplates.swift b/Charts/Classes/Utils/ChartColorTemplates.swift index c75941ce92..279d696422 100644 --- a/Charts/Classes/Utils/ChartColorTemplates.swift +++ b/Charts/Classes/Utils/ChartColorTemplates.swift @@ -201,6 +201,6 @@ public class ChartColorTemplates: NSObject ) } - return NSUIColor.clear() + return NSUIColor.clear } } diff --git a/Charts/Classes/Utils/ChartPlatform.swift b/Charts/Classes/Utils/ChartPlatform.swift index 259cfcdc77..6a24af007c 100644 --- a/Charts/Classes/Utils/ChartPlatform.swift +++ b/Charts/Classes/Utils/ChartPlatform.swift @@ -29,7 +29,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple { final func nsuiNumberOfTouches() -> Int { - return numberOfTouches() + return numberOfTouches } final var nsuiNumberOfTapsRequired: Int @@ -49,7 +49,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple { final func nsuiNumberOfTouches() -> Int { - return numberOfTouches() + return numberOfTouches } final func nsuiLocationOf(touch: Int, in view: UIView?) -> CGPoint @@ -192,7 +192,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple func NSUIMainScreen() -> NSUIScreen? { - return NSUIScreen.main() + return NSUIScreen.main } func NSUIGraphicsBeginImageContextWithOptions(size: CGSize, _ opaque: Bool, _ scale: CGFloat) diff --git a/Charts/Classes/Utils/ChartTransformer.swift b/Charts/Classes/Utils/ChartTransformer.swift index 801131e053..1c5bc01696 100644 --- a/Charts/Classes/Utils/ChartTransformer.swift +++ b/Charts/Classes/Utils/ChartTransformer.swift @@ -47,8 +47,8 @@ public class ChartTransformer: NSObject // setup all matrices _matrixValueToPx = CGAffineTransform.identity - _matrixValueToPx = _matrixValueToPx.scaleBy(x: scaleX, y: -scaleY) - _matrixValueToPx = _matrixValueToPx.translateBy(x: CGFloat(-chartXMin), y: CGFloat(-chartYMin)) + _matrixValueToPx = _matrixValueToPx.scaledBy(x: scaleX, y: -scaleY) + _matrixValueToPx = _matrixValueToPx.translatedBy(x: CGFloat(-chartXMin), y: CGFloat(-chartYMin)) } /// Prepares the matrix that contains all offsets. @@ -61,7 +61,7 @@ public class ChartTransformer: NSObject else { _matrixOffset = CGAffineTransform(scaleX: 1.0, y: -1.0) - _matrixOffset = _matrixOffset.translateBy(x: _viewPortHandler.offsetLeft, y: -_viewPortHandler.offsetTop) + _matrixOffset = _matrixOffset.translatedBy(x: _viewPortHandler.offsetLeft, y: -_viewPortHandler.offsetTop) } } @@ -106,19 +106,19 @@ public class ChartTransformer: NSObject let trans = valueToPixelMatrix for i in 0 ..< pts.count { - pts[i] = pts[i].apply(transform: trans) + pts[i] = pts[i].applying(trans) } } public func pointValueToPixel(_ point: inout CGPoint) { - point = point.apply(transform: valueToPixelMatrix) + point = point.applying(valueToPixelMatrix) } /// Transform a rectangle with all matrices. public func rectValueToPixel(_ r: inout CGRect) { - r = r.apply(transform: valueToPixelMatrix) + r = r.applying(valueToPixelMatrix) } /// Transform a rectangle with all matrices with potential animation phases. @@ -131,13 +131,13 @@ public class ChartTransformer: NSObject r.size.height = bottom - top r.origin.y = top - r = r.apply(transform: valueToPixelMatrix) + r = r.applying(valueToPixelMatrix) } /// Transform a rectangle with all matrices. public func rectValueToPixelHorizontal(_ r: inout CGRect) { - r = r.apply(transform: valueToPixelMatrix) + r = r.applying(valueToPixelMatrix) } /// Transform a rectangle with all matrices with potential animation phases. @@ -150,7 +150,7 @@ public class ChartTransformer: NSObject r.size.width = right - left r.origin.x = left - r = r.apply(transform: valueToPixelMatrix) + r = r.applying(valueToPixelMatrix) } /// transforms multiple rects with all matrices @@ -160,7 +160,7 @@ public class ChartTransformer: NSObject for i in 0 ..< rects.count { - rects[i] = rects[i].apply(transform: trans) + rects[i] = rects[i].applying(trans) } } @@ -171,14 +171,14 @@ public class ChartTransformer: NSObject for i in 0 ..< pixels.count { - pixels[i] = pixels[i].apply(transform: trans) + pixels[i] = pixels[i].applying(trans) } } /// Transforms the given touch point (pixels) into a value on the chart. public func pixelToValue(_ pixel: inout CGPoint) { - pixel = pixel.apply(transform: pixelToValueMatrix) + pixel = pixel.applying(pixelToValueMatrix) } /// - returns: the x and y values in the chart at the given touch point @@ -186,19 +186,19 @@ public class ChartTransformer: NSObject /// coordinates / values in the chart. public func getValueByTouchPoint(_ point: CGPoint) -> CGPoint { - return point.apply(transform: pixelToValueMatrix) + return point.applying(pixelToValueMatrix) } public var valueToPixelMatrix: CGAffineTransform { return - _matrixValueToPx.concat(_viewPortHandler.touchMatrix - ).concat(_matrixOffset + _matrixValueToPx.concatenating(_viewPortHandler.touchMatrix + ).concatenating(_matrixOffset ) } public var pixelToValueMatrix: CGAffineTransform { - return valueToPixelMatrix.invert() + return valueToPixelMatrix.inverted() } } diff --git a/Charts/Classes/Utils/ChartTransformerHorizontalBarChart.swift b/Charts/Classes/Utils/ChartTransformerHorizontalBarChart.swift index 58f29c645d..3be0626d2b 100644 --- a/Charts/Classes/Utils/ChartTransformerHorizontalBarChart.swift +++ b/Charts/Classes/Utils/ChartTransformerHorizontalBarChart.swift @@ -26,7 +26,7 @@ public class ChartTransformerHorizontalBarChart: ChartTransformer else { _matrixOffset = CGAffineTransform(scaleX: -1.0, y: 1.0) - _matrixOffset = _matrixOffset.translateBy(x: -(_viewPortHandler.chartWidth - _viewPortHandler.offsetRight), + _matrixOffset = _matrixOffset.translatedBy(x: -(_viewPortHandler.chartWidth - _viewPortHandler.offsetRight), y: _viewPortHandler.chartHeight - _viewPortHandler.offsetBottom) } } diff --git a/Charts/Classes/Utils/ChartUtils.swift b/Charts/Classes/Utils/ChartUtils.swift index 52d711429d..169769ae58 100755 --- a/Charts/Classes/Utils/ChartUtils.swift +++ b/Charts/Classes/Utils/ChartUtils.swift @@ -220,8 +220,8 @@ public class ChartUtils } context.saveGState() - context.translate(x: translate.x, y: translate.y) - context.rotate(byAngle: angleRadians) + context.translateBy(x: translate.x, y: translate.y) + context.rotate(by: angleRadians) (text as NSString).draw(at: drawOffset, withAttributes: attributes) @@ -270,8 +270,8 @@ public class ChartUtils } context.saveGState() - context.translate(x: translate.x, y: translate.y) - context.rotate(byAngle: angleRadians) + context.translateBy(x: translate.x, y: translate.y) + context.rotate(by: angleRadians) (text as NSString).draw(with: rect, options: .usesLineFragmentOrigin, attributes: attributes, context: nil) diff --git a/Charts/Classes/Utils/ChartViewPortHandler.swift b/Charts/Classes/Utils/ChartViewPortHandler.swift index acefb6f8ee..844e6b1941 100755 --- a/Charts/Classes/Utils/ChartViewPortHandler.swift +++ b/Charts/Classes/Utils/ChartViewPortHandler.swift @@ -176,15 +176,15 @@ public class ChartViewPortHandler: NSObject /// Zooms by the specified zoom factors. public func zoom(scaleX: CGFloat, scaleY: CGFloat) -> CGAffineTransform { - return _touchMatrix.scaleBy(x: scaleX, y: scaleY) + return _touchMatrix.scaledBy(x: scaleX, y: scaleY) } /// Zooms around the specified center public func zoom(scaleX: CGFloat, scaleY: CGFloat, x: CGFloat, y: CGFloat) -> CGAffineTransform { - var matrix = _touchMatrix.translateBy(x: x, y: y) - matrix = matrix.scaleBy(x: scaleX, y: scaleY) - matrix = matrix.translateBy(x: -x, y: -y) + var matrix = _touchMatrix.translatedBy(x: x, y: y) + matrix = matrix.scaledBy(x: scaleX, y: scaleY) + matrix = matrix.translatedBy(x: -x, y: -y) return matrix } @@ -215,9 +215,9 @@ public class ChartViewPortHandler: NSObject var matrix = _touchMatrix matrix.a = 1.0 matrix.d = 1.0 - matrix = matrix.translateBy(x: x, y: y) - matrix = matrix.scaleBy(x: scaleX, y: scaleY) - matrix = matrix.translateBy(x: -x, y: -y) + matrix = matrix.translatedBy(x: x, y: y) + matrix = matrix.scaledBy(x: scaleX, y: scaleY) + matrix = matrix.translatedBy(x: -x, y: -y) return matrix } @@ -236,7 +236,7 @@ public class ChartViewPortHandler: NSObject let translateX = pt.x - offsetLeft let translateY = pt.y - offsetTop - let matrix = _touchMatrix.concat(CGAffineTransform(translationX: -translateX, y: -translateY)) + let matrix = _touchMatrix.concatenating(CGAffineTransform(translationX: -translateX, y: -translateY)) return matrix } @@ -249,7 +249,7 @@ public class ChartViewPortHandler: NSObject let translateX = pt.x - offsetLeft let translateY = pt.y - offsetTop - let matrix = _touchMatrix.concat(CGAffineTransform(translationX: -translateX, y: -translateY)) + let matrix = _touchMatrix.concatenating(CGAffineTransform(translationX: -translateX, y: -translateY)) refresh(newMatrix: matrix, chart: chart, invalidate: true) }