Skip to content

Commit

Permalink
Make highlightFullBarEnabled feature work again
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Oct 19, 2016
1 parent b6a79cf commit 47b9793
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Source/Charts/Charts/BarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,20 @@ open class BarChartView: BarLineChartViewBase, BarChartDataProvider
Swift.print("Can't select by touch. No data set.")
return nil
}

return self.highlighter?.getHighlight(x: pt.x, y: pt.y)

guard let h = self.highlighter?.getHighlight(x: pt.x, y: pt.y)
else { return nil }

if !isHighlightFullBarEnabled { return h }

// For isHighlightFullBarEnabled, remove stackIndex
return Highlight(
x: h.x, y: h.y,
xPx: h.xPx, yPx: h.yPx,
dataIndex: h.dataIndex,
dataSetIndex: h.dataSetIndex,
stackIndex: -1,
axis: h.axis)
}

/// - returns: The bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be found in the charts data.
Expand Down
24 changes: 24 additions & 0 deletions Source/Charts/Charts/CombinedChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ open class CombinedChartView: BarLineChartViewBase, CombinedChartDataProvider
}
}

/// - returns: The Highlight object (contains x-index and DataSet index) of the selected value at the given touch point inside the CombinedChart.
open override func getHighlightByTouchPoint(_ pt: CGPoint) -> Highlight?
{
if _data === nil
{
Swift.print("Can't select by touch. No data set.")
return nil
}

guard let h = self.highlighter?.getHighlight(x: pt.x, y: pt.y)
else { return nil }

if !isHighlightFullBarEnabled { return h }

// For isHighlightFullBarEnabled, remove stackIndex
return Highlight(
x: h.x, y: h.y,
xPx: h.xPx, yPx: h.yPx,
dataIndex: h.dataIndex,
dataSetIndex: h.dataSetIndex,
stackIndex: -1,
axis: h.axis)
}

// MARK: - CombinedChartDataProvider

open var combinedData: CombinedChartData?
Expand Down

0 comments on commit 47b9793

Please sign in to comment.