Skip to content

Commit

Permalink
add switch for clearing lastHighlighted in clear() (ChartsOrg#2355)
Browse files Browse the repository at this point in the history
add switch for clearing `lastHighlighted` in clear()

fixing a bug: when clearing chart, the 'lastHighlighted' var isn't set to nil. This will cause user to tap twice to highlight the new value, if the new value's index is the same as the old 'lastHighlighted' var's.

* adding a switch

 it controls whether to clear the lasthighlighted value or not
  • Loading branch information
Eric0625 authored and liuxuan30 committed Apr 24, 2017
1 parent 3d79709 commit b7c4db0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Source/Charts/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate

/// flag that indicates if offsets calculation has already been done or not
fileprivate var _offsetsCalculated = false


/// if `true` , when call clear(), also set lastHighlighted to nil
open var clearLastHighlightedEnabled = false

/// array of Highlight objects that reference the highlighted slices in the chart
internal var _indicesToHighlight = [Highlight]()

Expand Down Expand Up @@ -276,6 +279,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
_data = nil
_offsetsCalculated = false
_indicesToHighlight.removeAll()
if clearLastHighlightedEnabled
{
lastHighlighted = nil
}
setNeedsDisplay()
}

Expand Down

0 comments on commit b7c4db0

Please sign in to comment.