PhilJay / MPAndroidChart

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.54k stars 9.01k forks source link

java.lang.NegativeArraySizeException: -2 #3008

Open musilto7 opened 7 years ago

musilto7 commented 7 years ago

java.lang.NegativeArraySizeException: -2 at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:178) at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:545) at com.github.mikephil.charting.renderer.CombinedChartRenderer.drawValues(CombinedChartRenderer.java:96) at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:261) at android.view.View.draw(View.java:17185)

This Problem is not caused by unsorted xValues. I is caused by animation. If I comment the:

combinedChart.animateXY(getAnimationDuration(),getAnimationDuration(), getAnimationEaseOption(), getAnimationEaseOption());

everything is ok.

I have two lineDataSets in my Graph. First line Axis dependency is left. Second line axisDependency is right.

If I look at the code in Tranformer: there is problem that min > max

min and max are counted in BarLineScatterCandleBubbleRenderer.

I think that problem could be in: float low = chart.getLowestVisibleX(); float high = chart.getHighestVisibleX();

I looked on getLowestVisibleX and getHighestVisibleX.

There is a implementation of getLowestVisibleX

@Override public float getLowestVisibleX() { getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom(), posForGetLowestVisibleX); float result = (float) Math.max(mXAxis.mAxisMinimum, posForGetLowestVisibleX.x); return result; }

I think that the right axis is ignored, it may cause the problem. getHighestVisibleX is the same case.

pramod-android commented 4 years ago

@musilto7 Did you get a solution for this?