From 1d44bdb7207acb5dd60b9131065f3415e03c773a Mon Sep 17 00:00:00 2001 From: Rick Date: Wed, 12 Apr 2017 21:36:39 +0200 Subject: [PATCH 1/3] Added an option to automatically hide the highlightLine after the touches have ended --- Source/Chart.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Chart.swift b/Source/Chart.swift index 1302f9fd1..35c64878e 100644 --- a/Source/Chart.swift +++ b/Source/Chart.swift @@ -167,6 +167,11 @@ open class Chart: UIControl { Width for the highlight line. */ open var highlightLineWidth: CGFloat = 0.5 + + /** + Wether we should automatically hide the highlightLine after touches have ended. + */ + open var shouldAutoHideHighlightLine: Bool = false /** Alpha component for the area's color. @@ -643,6 +648,8 @@ open class Chart: UIControl { fileprivate func drawHighlightLineFromLeftPosition(_ left: CGFloat) { if let shapeLayer = highlightShapeLayer { + shapeLayer.isHidden = false + // Use line already created let path = CGMutablePath() @@ -712,6 +719,7 @@ open class Chart: UIControl { override open func touchesEnded(_ touches: Set, with event: UIEvent?) { handleTouchEvents(touches, event: event) + highlightShapeLayer?.isHidden = shouldAutoHideHighlightLine delegate?.didEndTouchingChart(self) } @@ -790,4 +798,4 @@ open class Chart: UIControl { let dy2 = level - p2.y return (x: (p2.x * dy1 - p1.x * dy2) / (dy1 - dy2), y: level) } -} +} \ No newline at end of file From f382032c3d63d65970c439d5d6a60ef2db4c75e7 Mon Sep 17 00:00:00 2001 From: Rick Date: Wed, 12 Apr 2017 21:45:02 +0200 Subject: [PATCH 2/3] Updated readme Documented the `didEndTouchingChart` delegate method and the `shouldAutoHideHighlightLine` property. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b79a2c7d..188d5fc86 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,11 @@ class MyViewController: UIViewController, ChartDelegate { } func didFinishTouchingChart(chart: Chart) { - // Do something when finished + // Do something when finished (only called after the user swipes out of the chart either on the right or the left side) + } + + func didEndTouchingChart(chart: Chart) { + // Do something when the user ends touching the chart } } ``` @@ -196,6 +200,7 @@ There is no built-in method to update a chart. To accomplish this: * `delegate`: the delegate for listening to touch events. * `highlightLineColor`: color of the highlight line. * `highlightLineWidth`: width of the highlight line. +* `shouldAutoHideHighlightLine`: automatically hide the highlightLine after we've ended touching the chart. * `gridColor`: the grid color. * `labelColor`: the color of the labels. * `labelFont`: the font used for the labels. From def8b924b8977ae9e30808bbe10adcda1adba406 Mon Sep 17 00:00:00 2001 From: Rick Date: Wed, 12 Apr 2017 21:53:56 +0200 Subject: [PATCH 3/3] Renamed property shouldAutoHideHighlightLine to autoHideHighlightLine --- Source/Chart.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Chart.swift b/Source/Chart.swift index 35c64878e..632a98769 100644 --- a/Source/Chart.swift +++ b/Source/Chart.swift @@ -171,7 +171,7 @@ open class Chart: UIControl { /** Wether we should automatically hide the highlightLine after touches have ended. */ - open var shouldAutoHideHighlightLine: Bool = false + open var autoHideHighlightLine: Bool = false /** Alpha component for the area's color. @@ -719,7 +719,7 @@ open class Chart: UIControl { override open func touchesEnded(_ touches: Set, with event: UIEvent?) { handleTouchEvents(touches, event: event) - highlightShapeLayer?.isHidden = shouldAutoHideHighlightLine + highlightShapeLayer?.isHidden = autoHideHighlightLine delegate?.didEndTouchingChart(self) }