diff --git a/Source/Charts/Charts/ChartViewBase.swift b/Source/Charts/Charts/ChartViewBase.swift index 1b17d817fc..a5f7bd5e22 100755 --- a/Source/Charts/Charts/ChartViewBase.swift +++ b/Source/Charts/Charts/ChartViewBase.swift @@ -475,9 +475,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// This method will call the delegate. /// - parameter x: The x-value to highlight /// - parameter dataSetIndex: The dataset index to search in - @objc open func highlightValue(x: Double, dataSetIndex: Int) + /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) + @objc open func highlightValue(x: Double, dataSetIndex: Int, dataIndex: Int = -1) { - highlightValue(x: x, dataSetIndex: dataSetIndex, callDelegate: true) + highlightValue(x: x, dataSetIndex: dataSetIndex, dataIndex: dataIndex, callDelegate: true) } /// Highlights the value at the given x-value and y-value in the given DataSet. @@ -486,19 +487,21 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// - parameter x: The x-value to highlight /// - parameter y: The y-value to highlight. Supply `NaN` for "any" /// - parameter dataSetIndex: The dataset index to search in - @objc open func highlightValue(x: Double, y: Double, dataSetIndex: Int) + /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) + @objc open func highlightValue(x: Double, y: Double, dataSetIndex: Int, dataIndex: Int = -1) { - highlightValue(x: x, y: y, dataSetIndex: dataSetIndex, callDelegate: true) + highlightValue(x: x, y: y, dataSetIndex: dataSetIndex, dataIndex: dataIndex, callDelegate: true) } /// Highlights any y-value at the given x-value in the given DataSet. /// Provide -1 as the dataSetIndex to undo all highlighting. /// - parameter x: The x-value to highlight /// - parameter dataSetIndex: The dataset index to search in + /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) /// - parameter callDelegate: Should the delegate be called for this change - @objc open func highlightValue(x: Double, dataSetIndex: Int, callDelegate: Bool) + @objc open func highlightValue(x: Double, dataSetIndex: Int, dataIndex: Int = -1, callDelegate: Bool) { - highlightValue(x: x, y: Double.nan, dataSetIndex: dataSetIndex, callDelegate: callDelegate) + highlightValue(x: x, y: Double.nan, dataSetIndex: dataSetIndex, dataIndex: dataIndex, callDelegate: callDelegate) } /// Highlights the value at the given x-value and y-value in the given DataSet. @@ -506,8 +509,9 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// - parameter x: The x-value to highlight /// - parameter y: The y-value to highlight. Supply `NaN` for "any" /// - parameter dataSetIndex: The dataset index to search in + /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) /// - parameter callDelegate: Should the delegate be called for this change - @objc open func highlightValue(x: Double, y: Double, dataSetIndex: Int, callDelegate: Bool) + @objc open func highlightValue(x: Double, y: Double, dataSetIndex: Int, dataIndex: Int, callDelegate: Bool) { guard let data = _data else { @@ -521,7 +525,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate } else { - highlightValue(Highlight(x: x, y: y, dataSetIndex: dataSetIndex), callDelegate: callDelegate) + highlightValue(Highlight(x: x, y: y, dataSetIndex: dataSetIndex, dataIndex: dataIndex), callDelegate: callDelegate) } } diff --git a/Source/Charts/Highlight/Highlight.swift b/Source/Charts/Highlight/Highlight.swift index a0b585ea98..121c750e52 100644 --- a/Source/Charts/Highlight/Highlight.swift +++ b/Source/Charts/Highlight/Highlight.swift @@ -127,11 +127,13 @@ open class Highlight: NSObject /// - parameter x: the x-value of the highlighted value /// - parameter y: the y-value of the highlighted value /// - parameter dataSetIndex: the index of the DataSet the highlighted value belongs to - @objc public init(x: Double, y: Double, dataSetIndex: Int) + /// - parameter dataIndex: The data index to search in (only used in CombinedChartView currently) + @objc public init(x: Double, y: Double, dataSetIndex: Int, dataIndex: Int = -1) { _x = x _y = y _dataSetIndex = dataSetIndex + self.dataIndex = dataIndex } /// - parameter x: the x-value of the highlighted value