ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.52k stars 5.99k forks source link

App crashes because min is bigger than max in BarLineScatterCandleBubbleRenderer #4694

Open GinesSanchez-TopTracer opened 3 years ago

GinesSanchez-TopTracer commented 3 years ago

https://github.com/danielgindi/Charts/blob/e91ba716190836b013ef8a9ca53e220ad5051e21/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift#L137

I have the next dataSet:

Charts.ScatterChartDataSet, label: meanDistance, 33 entries: ChartDataEntry, x: -4.40704, y 6.406 ChartDataEntry, x: -13.644354, y 33.403999 ChartDataEntry, x: -21.630138, y 0.0 ChartDataEntry, x: -25.023655, y 0.0 ChartDataEntry, x: -17.247274, y 0.0 ChartDataEntry, x: -14.16761, y 0.0 ChartDataEntry, x: -25.32449, y 0.0 ChartDataEntry, x: -25.683102, y 0.0 ChartDataEntry, x: -40.0, y 0.0 ChartDataEntry, x: -24.422508, y 0.0 ChartDataEntry, x: -26.767139, y 0.0 ChartDataEntry, x: -29.922995, y 0.0 ChartDataEntry, x: -13.131207, y 0.0 ChartDataEntry, x: -25.449869, y 0.0 ChartDataEntry, x: -39.987324, y 0.0 ChartDataEntry, x: -40.0, y 0.0 ChartDataEntry, x: -28.313265, y 0.0 ChartDataEntry, x: -36.445889, y 0.0 ChartDataEntry, x: -40.0, y 0.0 ChartDataEntry, x: -40.0, y 0.0 ChartDataEntry, x: -20.190897, y 0.0 ChartDataEntry, x: -40.0, y 0.0 ChartDataEntry, x: -40.0, y 0.0 ChartDataEntry, x: -31.819294, y 0.0 ChartDataEntry, x: -40.0, y 0.0 ChartDataEntry, x: -22.258247, y 0.0 ChartDataEntry, x: -40.0, y 0.0 ChartDataEntry, x: 2.783774, y 0.0 ChartDataEntry, x: -28.920076, y 0.0 ChartDataEntry, x: -14.184858, y 0.0 ChartDataEntry, x: -40.0, y 251.194 ChartDataEntry, x: -15.427558, y 262.764008 ChartDataEntry, x: 23.794905, y 283.588989

in the function set(chart: BarLineScatterCandleBubbleChartDataProvider, dataSet: IBarLineScatterCandleBubbleChartDataSet, animator: Animator?) which set:

Making the app crashes in the line of code I mentioned at the beginning.

The points are golf shots where the x value is the Off Target Line and the y value of the flat Carry. In version 3.2.2 of Charts, the app works correctly with that data set.

kuemme01 commented 3 years ago

Same here

rjallanreal commented 3 years ago

I have a crash at same place. Previous issues related to this have referenced that this only happens when data is not sorted.

This is not the case for me. Instead, I have a crash when a pinch to zoom causes the first point on the x axis in the first data set to appear after the first point in a second data set. This causes the points to not be correctly ordered by the renderer, causing the crash

Edit: my diagnosis was wrong. In my case, the crash was actually because the library expects both data sets to have the same values on the x axis. That's an annoying limitation, but it is manageable in my case.

kscheff commented 3 years ago

This fixed it for me: PR #4647 and #4687

GinesSanchez-TopTracer commented 3 years ago

@kscheff Thanks for the fix. One more thing, the PRs are open for one month or more. Who has to approve them? I could help you with that.

liuxuan30 commented 3 years ago

@jjatie could you take a look?

liuxuan30 commented 3 years ago

@kscheff you listed two PRs, which fixed the issue? thanks

jiang443 commented 3 years ago

Same here. anyone has solution?

moyerr commented 2 years ago

I just ran into this after updating Charts. Any possibility of the fix getting merged anytime soon?

Karpot commented 2 years ago

Seen in 4.0.2 again. min was 1, max was 0 and range -1. Strange.

Digging into it, looks like the changes in open override func entryIndex() arent as resilient when out of range, so returning nil ...

kuzomenskyi commented 2 years ago

Moving back from Charts 4.0.0 to 3.6.0 solved the issue.