MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

use specail dataset entry cannot show “java.lang.NegativeArraySizeException: -38” in Transformer.java:178

Open rookielord opened this issue 2 years ago • 0 comments

Summary

when I use my special data to draw line(read them from text).My app suddenly crash.And I found it in logcat:

 at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:178)
        at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:562)
        at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:283)

Here is my situlation:

situlation result
add total 120 entres value cannot show line.it will crash when you scale the chart
add 45 entries value crash app right now
add 65 entries value show line

p.s. when I use excel it displays right

Expected Behavior When add all entries value or a part of them, the linechart can display right data

Possible Solution

Calulate scale wrong?Transformer cannot get right value to move.

Device (please complete the following information):

  • Device: [Mi 6]
  • Android Version [ 9.0]
  • Library Version (master directly clone)

Additional Context

Here is my data, and way to add it to dataset,you can change j in for loop to change range to fix the bug

    private void initData() {
        String content = "2023-07-13 15:15:25.644 25069-25069/ 其中的第0=123.0:0.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第1=131.0:0.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第2=133.0:1.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第3=116.0:1.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第4=111.0:1.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第5=110.0:1.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第6=113.0:2.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第7=117.0:2.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第8=117.0:2.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第9=134.0:2.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第10=215.0:3.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第11=220.0:3.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第12=165.0:3.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第13=138.0:3.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第14=142.0:4.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第15=138.0:4.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第16=139.0:4.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第17=138.0:4.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第18=128.0:5.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第19=141.0:5.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第20=148.0:5.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第21=156.0:5.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第22=176.0:6.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第23=188.0:6.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第24=162.0:6.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第25=143.0:6.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第26=141.0:7.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第27=141.0:7.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第28=143.0:7.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第29=141.0:7.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第30=140.0:8.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第31=140.0:8.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第32=139.0:8.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第33=142.0:8.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第34=155.0:9.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第35=164.0:9.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第36=165.0:9.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第37=164.0:9.75\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第38=161.0:10.0\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第39=158.0:10.25\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第40=152.0:10.5\n" +
                "2023-07-13 15:15:25.644 25069-25069/ 其中的第41=150.0:10.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第42=147.0:11.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第43=146.0:11.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第44=145.0:11.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第45=144.0:11.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第46=142.0:12.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第47=143.0:12.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第48=143.0:12.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第49=143.0:12.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第50=140.0:13.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第51=139.0:13.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第52=135.0:13.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第53=134.0:13.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第54=135.0:14.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第55=136.0:14.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第56=135.0:14.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第57=132.0:14.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第58=131.0:15.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第59=131.0:15.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第60=129.0:15.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第61=132.0:15.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第62=131.0:16.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第63=132.0:16.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第64=131.0:16.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第65=132.0:16.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第66=133.0:17.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第67=133.0:17.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第68=130.0:17.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第69=130.0:17.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第70=131.0:18.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第71=130.0:18.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第72=130.0:18.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第73=133.0:18.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第74=133.0:19.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第75=132.0:19.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第76=131.0:19.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第77=132.0:19.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第78=131.0:20.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第79=133.0:20.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第80=133.0:20.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第81=134.0:20.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第82=135.0:21.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第83=134.0:21.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第84=134.0:21.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第85=136.0:21.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第86=136.0:22.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第87=137.0:22.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第88=136.0:22.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第89=138.0:22.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第90=138.0:23.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第91=138.0:23.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第92=140.0:23.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第93=139.0:23.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第94=140.0:24.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第95=140.0:24.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第96=142.0:24.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第97=141.0:24.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第98=143.0:25.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第99=143.0:25.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第100=143.0:25.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第101=144.0:25.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第102=144.0:26.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第103=145.0:26.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第104=145.0:26.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第105=146.0:26.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第106=146.0:27.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第107=147.0:27.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第108=149.0:27.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第109=148.0:27.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第110=150.0:28.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第111=149.0:28.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第112=150.0:28.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第113=151.0:28.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第114=151.0:29.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第115=152.0:29.25\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第116=153.0:29.5\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第117=154.0:29.75\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第118=154.0:30.0\n" +
                "2023-07-13 15:15:25.645 25069-25069/ 其中的第119=154.0:30.25";
        String[] lines = content.split("\n");
        int i = 1;
        for (int j = 0; j < 45; j++) {
            String line = lines[i];
            Log.i("LJJ", "添加的点:" + line);
            String[] data = line.split("=");
            String value = data[data.length - 1];
            String[] numbers = value.split(":");
            mSet.addEntry(new Entry(Float.parseFloat(numbers[0]), Float.parseFloat(numbers[1])));
            i++;
        }
        mChart.getData().notifyDataChanged();
        mChart.notifyDataSetChanged();
        mChart.invalidate();
    }

ADD A REWARD using Speed to SOLVE this issue QUICKLY and SUPPORT this project.

rookielord avatar Jul 13 '23 09:07 rookielord