A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.64k
stars
9.02k
forks
source link
Negative Array Size Exception from LineChartRenderer #5321
Receiving the following NegativeArraySizeExcpetion:
E AndroidRuntime: java.lang.NegativeArraySizeException: -4
E AndroidRuntime: at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:178)
E AndroidRuntime: at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:549)
E AndroidRuntime: at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:278)
This occurs because of the following lines in LineChartRenderer:
Summary
Receiving the following NegativeArraySizeExcpetion: E AndroidRuntime: java.lang.NegativeArraySizeException: -4 E AndroidRuntime: at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:178) E AndroidRuntime: at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:549) E AndroidRuntime: at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:278)
This occurs because of the following lines in LineChartRenderer:
mXBounds.min is > mXBounds.max resulting in a negative number.
Expected Behavior
I expect max > min and the chart to render or the library to handle this case gracefully and not crash
Possible Solution
one solution would be to handle the negative case instead of trying to access the dataSet array using the negative index value.
Device (please complete the following information):
Additional Context
Below is a screenshot of the dataset provided:
Below is the mXBounds object: mXBounds = {BarLineScatterCandleBubbleRenderer$XBounds@26969} max = 2 min = 12 range = -10 this$0 = {LineChartRenderer@26967} shadow$klass = {Class@25640} "class com.github.mikephil.charting.renderer.BarLineScatterCandleBubbleRenderer$XBounds" shadow$monitor = 0
FYI, The X values are 10 digit epoch timestamps