-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
ChartData.removeEntryByXIndex removes the wrong entry #182
Comments
How exactly does constraining |
I've added: |
sorry for not mentioning it |
@dorsoft Oh now it makes sense. But shouldn't you check for nil first? |
you are right if (entry == nil || entry?.xIndex != xIndex) { |
@dorsoft Actually - my bad! It's Swift. It will check the optional for you when using an |
@dorsoft Do you want to open a PR? I'm not in front of Mac. Please format it according to the surrounding coding style and have a clean commit/PR :) |
Done |
ChartData.removeEntryByXIndex removes the wrong entry #182
scenario:
Expected result: no entry is removed and the method returns false
Actual result: the entry at xIndex 9 is removed, repeated method calls remove the last index (8,7,6...)
The fix:
public func removeEntryByXIndex(xIndex: Int, dataSetIndex: Int) -> Bool
{
if (dataSetIndex >= _dataSets.count)
{
return false
}
var entry = _dataSets[dataSetIndex].entryForXIndex(xIndex)
if (entry?.xIndex != xIndex) {
return false
}
return removeEntry(entry, dataSetIndex: dataSetIndex)
}
The text was updated successfully, but these errors were encountered: