diff --git a/Source/Chart.swift b/Source/Chart.swift index 763b830a1..54d5c2516 100644 --- a/Source/Chart.swift +++ b/Source/Chart.swift @@ -284,6 +284,17 @@ open class Chart: UIControl { return series.data[dataIndex!].y } + /** + Finish touching the chart, by removing the highlight line and calling the delegate method. + */ + public func finishTouchingChart() { + // Remove highlight line at the end of the touch event + if let shapeLayer = highlightShapeLayer { + shapeLayer.path = nil + } + delegate?.didFinishTouchingChart(self) + } + fileprivate func drawIBPlaceholder() { let placeholder = UIView(frame: self.frame) placeholder.backgroundColor = UIColor(red: 0.93, green: 0.93, blue: 0.93, alpha: 1) @@ -719,11 +730,7 @@ open class Chart: UIControl { let x = valueFromPointAtX(left) if left < 0 || left > (drawingWidth as CGFloat) { - // Remove highlight line at the end of the touch event - if let shapeLayer = highlightShapeLayer { - shapeLayer.path = nil - } - delegate?.didFinishTouchingChart(self) + finishTouchingChart() return } @@ -748,8 +755,8 @@ open class Chart: UIControl { } delegate!.didTouchChart(self, indexes: indexes, x: x, left: left) - } + override open func touchesBegan(_ touches: Set, with event: UIEvent?) { handleTouchEvents(touches, event: event) }