diff --git a/README.md b/README.md index 7e31c3bf9..d72ecf39f 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,7 @@ Some tips for debugging an hidden chart: * `delegate` – the delegate for listening to touch events. * `highlightLineColor` – color of the highlight line. * `highlightLineWidth` – width of the highlight line. +* `removesHighlighLineOnTouchesEnded` (default `false`) – if true will hide the highlight line as soon as you stop swiping over the chart. * `gridColor` – the grid color. * `labelColor` – the color of the labels. * `labelFont` – the font used for the labels. diff --git a/Source/Chart.swift b/Source/Chart.swift index 763b830a1..d3f7b0cc2 100644 --- a/Source/Chart.swift +++ b/Source/Chart.swift @@ -194,6 +194,10 @@ open class Chart: UIControl { Width for the highlight line. */ open var highlightLineWidth: CGFloat = 0.5 + /** + Removes highlight line when touches end. + */ + open var removesHighlighLineOnTouchesEnded = false /** Alpha component for the area's color. @@ -756,6 +760,11 @@ open class Chart: UIControl { override open func touchesEnded(_ touches: Set, with event: UIEvent?) { handleTouchEvents(touches, event: event) + if self.removesHighlighLineOnTouchesEnded { + if let shapeLayer = highlightShapeLayer { + shapeLayer.path = nil + } + } delegate?.didEndTouchingChart(self) }