Repository: PhilJay/MPAndroidChart

Issue #2450: Invalid index 0, size is 0 in lineChart
Created: 2016-11-09T11:49:05Z
in the first, I add an empty chart data ,then
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
11-09 19:34:42.397 E/AndroidRuntime( 5201): 	at             java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
11-09 19:34:42.397 E/AndroidRuntime( 5201): 	at java.util.ArrayList.get(ArrayList.java:308)
11-09 19:34:42.397 E/AndroidRuntime( 5201): 	at com.github.mikephil.charting.data.DataSet.getEntryForIndex(DataSet.java:286)
11-09 19:34:42.397 E/AndroidRuntime( 5201): 	at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:184)
11-09 19:34:42.397 E/AndroidRuntime( 5201): 	at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:545)
11-09 19:34:42.397 E/AndroidRuntime( 5201): 	at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:251)

I think it is because of you dont check size when you draw values

Duplicate issue #2455: LineChart | Crash if LineDataSet is empty.
Created: 2016-11-10T09:40:17Z
Hi,
I just updated from beta to stable and now the activity crash.
After a few of tests I have found that append if a LineDataSet is empty and is added to a LineData.
public class ChartActivity extends AppCompatActivity {
    @BindView(R.id.chart)
    LineChart mChart;

    LineData mData;
    LineDataSet mDataSet;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chart);

        ButterKnife.bind(this);

        mData = new LineData();
        mChart.setData(mData);
        mChart.invalidate();

        mDataSet = new LineDataSet(null, "Weight");

        // If you add a value works
        mDataSet.addEntry(new Entry(0, 5));

        mData.addDataSet(mDataSet);
        mData.notifyDataChanged();
    }
}

FATAL EXCEPTION: main
    Process: it.rblab.mydemochart, PID: 6312
    java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
     at java.util.ArrayList.get(ArrayList.java:308)
     at com.github.mikephil.charting.data.DataSet.getEntryForIndex(DataSet.java:286)
     at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:184)
     at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:545)
     at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:251)
     at android.view.View.draw(View.java)
     at android.view.View.updateDisplayListIfDirty(View.java)
     at android.view.View.getDisplayList(View.java)
     at android.view.View.draw(View.java)
     at android.view.ViewGroup.drawChild(ViewGroup.java)
     at android.view.ViewGroup.dispatchDraw(ViewGroup.java)
     at android.view.View.updateDisplayListIfDirty(View.java)
     at android.view.View.getDisplayList(View.java)
     at android.view.View.draw(View.java)
     at android.view.ViewGroup.drawChild(ViewGroup.java)
     at android.view.ViewGroup.dispatchDraw(ViewGroup.java)
     at android.view.View.updateDisplayListIfDirty(View.java)
     at android.view.View.getDisplayList(View.java)
     at android.view.View.draw(View.java)
     at android.view.ViewGroup.drawChild(ViewGroup.java)
     at android.view.ViewGroup.dispatchDraw(ViewGroup.java)
     at android.view.View.updateDisplayListIfDirty(View.java)
     at android.view.View.getDisplayList(View.java)
     at android.view.View.draw(View.java)
     at android.view.ViewGroup.drawChild(ViewGroup.java)
     at android.view.ViewGroup.dispatchDraw(ViewGroup.java)
     at android.view.View.updateDisplayListIfDirty(View.java)
     at android.view.View.getDisplayList(View.java)
     at android.view.View.draw(View.java)
     at android.view.ViewGroup.drawChild(ViewGroup.java)
     at android.view.ViewGroup.dispatchDraw(ViewGroup.java)
     at android.view.View.updateDisplayListIfDirty(View.java)
     at android.view.View.getDisplayList(View.java)
     at android.view.View.draw(View.java)
     at android.view.ViewGroup.drawChild(ViewGroup.java)
     at android.view.ViewGroup.dispatchDraw(ViewGroup.java)
     at android.view.View.draw(View.java)
     at android.widget.FrameLayout.draw(FrameLayout.java)
     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2653)
     at android.view.View.updateDisplayListIfDirty(View.java)
     at android.view.View.getDisplayList(View.java)
     at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java)
     at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java)
     at android.view.ThreadedRenderer.draw(ThreadedRenderer.java)
     at android.view.ViewRootImpl.draw(ViewRootImpl.java)
     at android.view.ViewRootImpl.performDraw(ViewRootImpl.java)
     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java)
     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java)
     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java)
     at android.view.Choreographer$CallbackRecord.run(Choreographer.java)
     at android.view.Choreographer.doCallbacks(Choreographer.java)
     at android.view.Choreographer.doFrame(Choreographer.java)
     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java)
     at android.os.Handler.handleCallback(Handler.java)
     at android.os.Handler.dispatchMessage(Handler.java)
     at android.os.Looper.loop(Looper.java)
     at android.app.ActivityThread.main(ActivityThread.java)
     at java.lang.reflect.Method.invoke(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
     at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:163)

Closing comment (2017-07-06T06:10:44Z): This is a duplicate of #2450