Charts icon indicating copy to clipboard operation
Charts copied to clipboard

App crashes because min is bigger than max in BarLineScatterCandleBubbleRenderer

Open GinesSanchez-TopTracer opened this issue 3 years ago • 10 comments

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:

  • min to 20.
  • max to 10.
  • range to 0.

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.

GinesSanchez-TopTracer avatar Aug 03 '21 08:08 GinesSanchez-TopTracer

Same here

kuemme01 avatar Aug 11 '21 07:08 kuemme01

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.

rjallanreal avatar Aug 11 '21 22:08 rjallanreal

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

kscheff avatar Aug 12 '21 14:08 kscheff

@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.

GinesSanchez-TopTracer avatar Aug 12 '21 15:08 GinesSanchez-TopTracer

@jjatie could you take a look?

liuxuan30 avatar Aug 13 '21 11:08 liuxuan30

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

liuxuan30 avatar Aug 13 '21 11:08 liuxuan30

Same here. anyone has solution?

jiang443 avatar Sep 08 '21 03:09 jiang443

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

moyerr avatar Nov 09 '21 18:11 moyerr

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 ...

Karpot avatar Mar 21 '22 12:03 Karpot

Moving back from Charts 4.0.0 to 3.6.0 solved the issue.

kuzomenskyi avatar Jul 21 '22 08:07 kuzomenskyi