From 767d03d5c904d97fed49e41ec79d61f6cc7d8d50 Mon Sep 17 00:00:00 2001 From: Anton Doudarev Date: Sun, 26 Aug 2018 17:48:35 -0400 Subject: [PATCH 1/3] Added delegate callback to detect when panning is finished, to potentially allow users to manually reset the hightlight values once panning is complete --- Source/Charts/Charts/BarLineChartViewBase.swift | 2 ++ Source/Charts/Charts/ChartViewBase.swift | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Source/Charts/Charts/BarLineChartViewBase.swift b/Source/Charts/Charts/BarLineChartViewBase.swift index b64baba3bf..e25c94975b 100644 --- a/Source/Charts/Charts/BarLineChartViewBase.swift +++ b/Source/Charts/Charts/BarLineChartViewBase.swift @@ -779,6 +779,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD } _isDragging = false + + delegate?.chartViewDidEndPanning?(self) } if _outerScrollView !== nil diff --git a/Source/Charts/Charts/ChartViewBase.swift b/Source/Charts/Charts/ChartViewBase.swift index 7528e0c75b..60f0606844 100644 --- a/Source/Charts/Charts/ChartViewBase.swift +++ b/Source/Charts/Charts/ChartViewBase.swift @@ -25,6 +25,9 @@ public protocol ChartViewDelegate /// - parameter highlight: The corresponding highlight object that contains information about the highlighted position such as dataSetIndex etc. @objc optional func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) + /// Called when a user stop highlighting values while panning + @objc optional func chartViewDidEndPanning(_ chartView: ChartViewBase) + // Called when nothing has been selected or an "un-select" has been made. @objc optional func chartValueNothingSelected(_ chartView: ChartViewBase) From c3d3ed7975487862b3504809ce5c1cb4d587df08 Mon Sep 17 00:00:00 2001 From: Anton Doudarev Date: Sun, 26 Aug 2018 18:03:32 -0400 Subject: [PATCH 2/3] Changed the part of the code where the delegate gets called --- Source/Charts/Charts/BarLineChartViewBase.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Charts/Charts/BarLineChartViewBase.swift b/Source/Charts/Charts/BarLineChartViewBase.swift index e25c94975b..fad97d9928 100644 --- a/Source/Charts/Charts/BarLineChartViewBase.swift +++ b/Source/Charts/Charts/BarLineChartViewBase.swift @@ -779,8 +779,6 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD } _isDragging = false - - delegate?.chartViewDidEndPanning?(self) } if _outerScrollView !== nil @@ -788,6 +786,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD _outerScrollView?.nsuiIsScrollEnabled = true _outerScrollView = nil } + + delegate?.chartViewDidEndPanning?(self) } } From 33e8eb1d81624a07789d5cceaaf63de29888cf14 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 10 Oct 2018 09:00:34 -0400 Subject: [PATCH 3/3] Update ChartViewBase.swift Updated documentation in the code based on feedback --- Source/Charts/Charts/ChartViewBase.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Charts/Charts/ChartViewBase.swift b/Source/Charts/Charts/ChartViewBase.swift index 60f0606844..f06c731e1f 100644 --- a/Source/Charts/Charts/ChartViewBase.swift +++ b/Source/Charts/Charts/ChartViewBase.swift @@ -25,7 +25,7 @@ public protocol ChartViewDelegate /// - parameter highlight: The corresponding highlight object that contains information about the highlighted position such as dataSetIndex etc. @objc optional func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) - /// Called when a user stop highlighting values while panning + /// Called when a user stops panning between values on the chart @objc optional func chartViewDidEndPanning(_ chartView: ChartViewBase) // Called when nothing has been selected or an "un-select" has been made.