diff --git a/Source/Charts/Charts/BarLineChartViewBase.swift b/Source/Charts/Charts/BarLineChartViewBase.swift index 135b707728..3450cfba6e 100644 --- a/Source/Charts/Charts/BarLineChartViewBase.swift +++ b/Source/Charts/Charts/BarLineChartViewBase.swift @@ -156,7 +156,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD } else { - let _ = viewPortHandler.refresh(newMatrix: viewPortHandler.touchMatrix, chart: self, invalidate: true) + viewPortHandler.refresh(newMatrix: viewPortHandler.touchMatrix, chart: self, invalidate: true) } } @@ -648,7 +648,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD matrix = _viewPortHandler.touchMatrix.concatenating(matrix) - let _ = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: true) + _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: true) if delegate !== nil { @@ -971,7 +971,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD let center = _viewPortHandler.contentCenter let matrix = _viewPortHandler.zoomIn(x: center.x, y: -center.y) - let _ = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) + _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) // Range might have changed, which means that Y-axis labels could have changed in size, affecting Y-axis size. So we need to recalculate offsets. calculateOffsets() @@ -984,7 +984,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD let center = _viewPortHandler.contentCenter let matrix = _viewPortHandler.zoomOut(x: center.x, y: -center.y) - let _ = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) + _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) // Range might have changed, which means that Y-axis labels could have changed in size, affecting Y-axis size. So we need to recalculate offsets. calculateOffsets() @@ -995,7 +995,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD @objc open func resetZoom() { let matrix = _viewPortHandler.resetZoom() - let _ = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) + _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) // Range might have changed, which means that Y-axis labels could have changed in size, affecting Y-axis size. So we need to recalculate offsets. calculateOffsets() @@ -1016,7 +1016,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD y: CGFloat) { let matrix = _viewPortHandler.zoom(scaleX: scaleX, scaleY: scaleY, x: x, y: -y) - let _ = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) + _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) // Range might have changed, which means that Y-axis labels could have changed in size, affecting Y-axis size. So we need to recalculate offsets. calculateOffsets() @@ -1067,7 +1067,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD scaleY: scaleY, x: center.x, y: -center.y) - let _ = viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) + viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) } /// Zooms by the specified scale factor to the specified values on the specified axis. @@ -1157,7 +1157,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD @objc open func fitScreen() { let matrix = _viewPortHandler.fitScreen() - let _ = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) + _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) calculateOffsets() setNeedsDisplay() diff --git a/Source/Charts/Jobs/AnimatedViewPortJob.swift b/Source/Charts/Jobs/AnimatedViewPortJob.swift index dbde0bf4b1..1db96e0645 100644 --- a/Source/Charts/Jobs/AnimatedViewPortJob.swift +++ b/Source/Charts/Jobs/AnimatedViewPortJob.swift @@ -76,23 +76,20 @@ open class AnimatedViewPortJob: ViewPortJob @objc open func stop(finish: Bool) { - if _displayLink != nil + guard _displayLink != nil else { return } + _displayLink.remove(from: RunLoop.main, forMode: RunLoopMode.commonModes) + _displayLink = nil + + if finish { - _displayLink.remove(from: RunLoop.main, forMode: RunLoopMode.commonModes) - _displayLink = nil - - if finish + if phase != 1.0 { - if phase != 1.0 - { - phase = 1.0 - phase = 1.0 - - animationUpdate() - } - - animationEnd() + phase = 1.0 + + animationUpdate() } + + animationEnd() } } @@ -132,11 +129,11 @@ open class AnimatedViewPortJob: ViewPortJob @objc internal func animationUpdate() { - // Override this + fatalError("`animationUpdate()` must be overriden by subclasses") } @objc internal func animationEnd() { - // Override this + fatalError("`animationEnd()` must be overriden by subclasses") } } diff --git a/Source/Charts/Jobs/AnimatedZoomViewJob.swift b/Source/Charts/Jobs/AnimatedZoomViewJob.swift index 3ad1959cfc..297f46a5b8 100644 --- a/Source/Charts/Jobs/AnimatedZoomViewJob.swift +++ b/Source/Charts/Jobs/AnimatedZoomViewJob.swift @@ -72,7 +72,7 @@ open class AnimatedZoomViewJob: AnimatedViewPortJob let scaleY = yOrigin + (self.scaleY - yOrigin) * phase var matrix = viewPortHandler.setZoom(scaleX: scaleX, scaleY: scaleY) - let _ = viewPortHandler.refresh(newMatrix: matrix, chart: view, invalidate: false) + viewPortHandler.refresh(newMatrix: matrix, chart: view, invalidate: false) let valsInView = CGFloat(yAxis?.axisRange ?? 0.0) / viewPortHandler.scaleY let xsInView = CGFloat(xAxisRange) / viewPortHandler.scaleX @@ -85,7 +85,7 @@ open class AnimatedZoomViewJob: AnimatedViewPortJob transformer.pointValueToPixel(&pt) matrix = viewPortHandler.translate(pt: pt) - let _ = viewPortHandler.refresh(newMatrix: matrix, chart: view, invalidate: true) + viewPortHandler.refresh(newMatrix: matrix, chart: view, invalidate: true) } internal override func animationEnd() diff --git a/Source/Charts/Jobs/MoveViewJob.swift b/Source/Charts/Jobs/MoveViewJob.swift index b175b1707e..81a8774ee0 100644 --- a/Source/Charts/Jobs/MoveViewJob.swift +++ b/Source/Charts/Jobs/MoveViewJob.swift @@ -18,22 +18,7 @@ import CoreGraphics @objc(MoveChartViewJob) open class MoveViewJob: ViewPortJob -{ - public override init( - viewPortHandler: ViewPortHandler, - xValue: Double, - yValue: Double, - transformer: Transformer, - view: ChartViewBase) - { - super.init( - viewPortHandler: viewPortHandler, - xValue: xValue, - yValue: yValue, - transformer: transformer, - view: view) - } - +{ open override func doJob() { guard diff --git a/Source/Charts/Jobs/ViewPortJob.swift b/Source/Charts/Jobs/ViewPortJob.swift index 42f9b76783..1735d5cd01 100644 --- a/Source/Charts/Jobs/ViewPortJob.swift +++ b/Source/Charts/Jobs/ViewPortJob.swift @@ -41,6 +41,6 @@ open class ViewPortJob: NSObject @objc open func doJob() { - // Override this + fatalError("`doJob()` must be overridden by subclasses") } } diff --git a/Source/Charts/Jobs/ZoomViewJob.swift b/Source/Charts/Jobs/ZoomViewJob.swift index 7a6c8d8911..e86e055f90 100644 --- a/Source/Charts/Jobs/ZoomViewJob.swift +++ b/Source/Charts/Jobs/ZoomViewJob.swift @@ -54,7 +54,7 @@ open class ZoomViewJob: ViewPortJob else { return } var matrix = viewPortHandler.setZoom(scaleX: scaleX, scaleY: scaleY) - let _ = viewPortHandler.refresh(newMatrix: matrix, chart: view, invalidate: false) + viewPortHandler.refresh(newMatrix: matrix, chart: view, invalidate: false) let yValsInView = (view as! BarLineChartViewBase).getAxis(axisDependency).axisRange / Double(viewPortHandler.scaleY) let xValsInView = (view as! BarLineChartViewBase).xAxis.axisRange / Double(viewPortHandler.scaleX) @@ -67,7 +67,7 @@ open class ZoomViewJob: ViewPortJob transformer.pointValueToPixel(&pt) matrix = viewPortHandler.translate(pt: pt) - let _ = viewPortHandler.refresh(newMatrix: matrix, chart: view, invalidate: false) + viewPortHandler.refresh(newMatrix: matrix, chart: view, invalidate: false) (view as! BarLineChartViewBase).calculateOffsets() view.setNeedsDisplay() diff --git a/Source/Charts/Utils/ViewPortHandler.swift b/Source/Charts/Utils/ViewPortHandler.swift index 6e184e0b3f..55fc752cfd 100755 --- a/Source/Charts/Utils/ViewPortHandler.swift +++ b/Source/Charts/Utils/ViewPortHandler.swift @@ -255,12 +255,11 @@ open class ViewPortHandler: NSObject let translateY = pt.y - offsetTop let matrix = _touchMatrix.concatenating(CGAffineTransform(translationX: -translateX, y: -translateY)) - - let _ = refresh(newMatrix: matrix, chart: chart, invalidate: true) + refresh(newMatrix: matrix, chart: chart, invalidate: true) } /// call this method to refresh the graph with a given matrix - @objc open func refresh(newMatrix: CGAffineTransform, chart: ChartViewBase, invalidate: Bool) -> CGAffineTransform + @objc @discardableResult open func refresh(newMatrix: CGAffineTransform, chart: ChartViewBase, invalidate: Bool) -> CGAffineTransform { _touchMatrix = newMatrix