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

Fix bounds checks on binary search #4577

Merged
merged 1 commit into from
Feb 9, 2021
Merged

Conversation

jjatie
Copy link
Collaborator

@jjatie jjatie commented Feb 7, 2021

Issue Link 🔗

#4571

Implementation Details 🚧

Incorrectly returned index beyond the last valid index. This is now corrected

@jjatie jjatie requested a review from liuxuan30 February 7, 2021 04:10
@jjatie jjatie merged commit 931ebe8 into master Feb 9, 2021
@jjatie jjatie deleted the bugfix/binary-search-bounds-fix branch February 9, 2021 21:08
@InvaderZim62
Copy link

This change and possibly the changes leading up to it caused LineChartData(dataSets:) to stop plotting all data points, if the LineChartDataSet entries are not all the same size. Only the first point is plotted for the shorter data set. To reproduce, run this code:

let chart = LineChartView()
chart.data = LineChartData(
    dataSets: [
        LineChartDataSet(entries: [
            ChartDataEntry(x: 0, y: 0),
            ChartDataEntry(x: 10, y: 10),
            ChartDataEntry(x: 20, y: 20)
        ]),
        LineChartDataSet(entries: [
            ChartDataEntry(x: 0, y: 5),
            ChartDataEntry(x: 10, y: 15)
        ])
    ]
)

When I reverted back to the earlier commit 857db24 this code plots all five data points.

abhiramvadlapatla pushed a commit to abhiramvadlapatla/Charts that referenced this pull request Dec 21, 2021
zebraciam added a commit to zebraciam/Charts that referenced this pull request Jul 6, 2022
* master:
  update changelog.
  Fixed incorrect guard return statement when rendering limit lines (ChartsOrg#4563)
  Fix bounds checks on binary search (ChartsOrg#4577)
  Added SPM build action (ChartsOrg#4576)
  Replace FBSnapshotTestCase with pointfree/swift-snapshot-testing (ChartsOrg#4574)
  Import swift algorithms (ChartsOrg#4497)
  ChartViewBase cleanup (ChartsOrg#4537)
  SPM GitHub Action (ChartsOrg#4553)
  Algorithm updates (ChartsOrg#3638)
  Added SPM Install section
  Update README.md
  Fix missing drawIconsEnabled parameter initialization in the copying constructor of the ChartBaseDataSet (ChartsOrg#4424)
  Resolve conflict for 4.0 branch and master (ChartsOrg#4456)
  Alternative for SPM dynamic linking (ChartsOrg#4478)
  3.6.0 changelog

# Conflicts:
#	Source/Charts/Renderers/LineChartRenderer.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants