Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For #2840. add dataIndex parameter in highlightValue() calls #2852

Merged
merged 2 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Source/Charts/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -486,28 +487,31 @@ 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: .nan, dataSetIndex: dataSetIndex, dataIndex: dataIndex, callDelegate: callDelegate)
}

/// Highlights the value at the given x-value and y-value in the given DataSet.
/// Provide -1 as the dataSetIndex to undo all highlighting.
/// - 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 = -1, callDelegate: Bool)
{
guard let data = _data else
{
Expand All @@ -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)
}
}

Expand Down
4 changes: 3 additions & 1 deletion Source/Charts/Highlight/Highlight.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down