Java MPAndroid图表库,通过setValueFormatter设置标签时出现问题

Java MPAndroid图表库,通过setValueFormatter设置标签时出现问题,java,android,mpandroidchart,Java,Android,Mpandroidchart,我正在尝试绘制条形图,并希望在条形图上设置标签。但最后一个条目的标签未显示。下面是我如何设置图表的。machines arraylist包含标签,我将其复制到字符串数组mac[]中 String[] mac = new String[machines.size()];; for(int i=0;i<machines.size();++i) { mac[i] = machines.get(i

我正在尝试绘制条形图,并希望在条形图上设置标签。但最后一个条目的标签未显示。下面是我如何设置图表的。machines arraylist包含标签,我将其复制到字符串数组mac[]中

            String[] mac = new String[machines.size()];;
            for(int i=0;i<machines.size();++i)
            {
               mac[i] = machines.get(i);
            }


            BarChart chart1 = (BarChart) findViewById(R.id.chart1);
            BarDataSet bds2 = new BarDataSet(barEntries, "Target");
            BarDataSet bds1 = new BarDataSet(barEntries1,"Prepared");
            bds1.setColor(Color.parseColor("#F44336"));
            BarData ddata1 = new BarData(bds1,bds2);
            chart1.setScaleEnabled(true);
            chart1.setPinchZoom(true);
            chart1.setData(ddata1);
            XAxis xa1 = chart1.getXAxis();
            xa1.setValueFormatter(new MyAxisValueFormatter(mac));

            xa1.setCenterAxisLabels(true);
            chart1.setTouchEnabled(true);
            chart1.setDragEnabled(true);
            chart1.setScaleEnabled(true);
            float groupSpace = 0.0f;
            float barSpace = 0.0f; 
            chart1.fitScreen();
            ddata1.setBarWidth(barWidth);
            xa1.setLabelCount(machines.size(),true);
            chart1.groupBars( 0.0f,groupSpace, barSpace);
            chart1.setFitBars(true); // make the x-axis fit exactly all bars
            chart1.setVisibility(View.VISIBLE);
            xa1.setGranularity(1f);
            xa1.setAxisMinimum(0);
            xa1.setGranularityEnabled(true);
            xa1.setCenterAxisLabels(true);
            chart1.invalidate();
现在我非常确定machines arraylist的大小是12,但是我的图表上的标签数量只有11个,也就是说,没有显示最后一个标签。我尝试在日志中MyAxisValueFormatter类的getFormattedValue函数中显示变量。还有这个。根据文档,“值”表示标签在轴(x或y)上的位置

记录如下:

07-24 21:21:28.299 26339-26339/com.example.quickstart I/flag: -0.5
07-24 21:21:28.300 26339-26339/com.example.quickstart I/flag: 0.5909091
    1.6818182
    2.7727275
    3.8636365
    4.9545455
    6.0454545
    7.1363635
    8.227273
    9.318182
    10.409091
    11.5
07-24 21:21:28.304 26339-26339/com.example.quickstart I/flag: 0.0
    1.0681819
    2.1363637
    3.2045455
    4.2727275
    5.3409095
07-24 21:21:28.305 26339-26339/com.example.quickstart I/flag: 6.4090915
    7.4772735
    8.545455
    9.613637
    10.681819
    11.750001
07-24 21:21:28.310 26339-26339/com.example.quickstart I/flag: 0.0
    1.0681819
    2.1363637
    3.2045455
    4.2727275
    5.3409095
    6.4090915
    7.4772735
    8.545455
    9.613637
07-24 21:21:28.311 26339-26339/com.example.quickstart I/flag: 10.681819
    11.750001
07-24 21:21:28.313 26339-26339/com.example.quickstart I/flag: 0.0
    1.0681819
07-24 21:21:28.314 26339-26339/com.example.quickstart I/flag: 2.1363637
07-24 21:21:28.315 26339-26339/com.example.quickstart I/flag: 3.2045455
    4.2727275
    5.3409095
07-24 21:21:28.316 26339-26339/com.example.quickstart I/flag: 6.4090915
    7.4772735
07-24 21:21:28.317 26339-26339/com.example.quickstart I/flag: 8.545455
    9.613637
07-24 21:21:28.318 26339-26339/com.example.quickstart I/flag: 10.681819
07-24 21:21:28.344 26339-26339/com.example.quickstart I/flag: 0.0
07-24 21:21:28.345 26339-26339/com.example.quickstart I/flag: 1.0681819
    2.1363637
    3.2045455
    4.2727275
    5.3409095
    6.4090915
    7.4772735
    8.545455
    9.613637
    10.681819
    11.750001
07-24 21:21:28.348 26339-26339/com.example.quickstart I/flag: 0.0
    1.0681819
07-24 21:21:28.349 26339-26339/com.example.quickstart I/flag: 2.1363637
    3.2045455
    4.2727275
07-24 21:21:28.350 26339-26339/com.example.quickstart I/flag: 5.3409095
    6.4090915
    7.4772735
07-24 21:21:28.351 26339-26339/com.example.quickstart I/flag: 8.545455
    9.613637
    10.681819
现在我不明白为什么不在最后一行打印11.750001。还有,为什么x的值会增加0.6左右,从0增加到1.0681819,而不是1。我可能犯了一个小错误,这导致我的标签在轴上的定位混乱。我只想显示我所有的标签。请调查一下。感谢您的帮助

这是我当前跑步应用程序的一个缩影。正如您所看到的,只有11个标签,而实际上应该有12个

编辑:

BAENTRIES值为FTP12之后的值:

07-24 21:56:50.612 1755-1982/com.example.quickstart I/FTP12: 0000002500 
07-24 21:56:50.615 1755-1982/com.example.quickstart I/FTP12: 0000007350 
07-24 21:56:50.619 1755-1982/com.example.quickstart I/FTP12: 0000004500 
07-24 21:56:50.622 1755-1982/com.example.quickstart I/FTP12: 0000007000 
07-24 21:56:50.624 1755-1982/com.example.quickstart I/FTP12: 0000007000 
07-24 21:56:50.626 1755-1982/com.example.quickstart I/FTP12: 0000003500 
07-24 21:56:50.628 1755-1982/com.example.quickstart I/FTP12: 0000009000 
07-24 21:56:50.631 1755-1982/com.example.quickstart I/FTP12: 0000007151 
07-24 21:56:50.633 1755-1982/com.example.quickstart I/FTP12: 0000004378 
07-24 21:56:50.635 1755-1982/com.example.quickstart I/FTP12: 0000006810 
07-24 21:56:50.637 1755-1982/com.example.quickstart I/FTP12: 0000003405 
07-24 21:56:50.639 1755-1982/com.example.quickstart I/FTP12: 0000008756 
barentries1值是,barentries1之后的值:

07-24 21:59:20.008 3331-3435/com.example.quickstart I/barentries1: 000000000001504 
07-24 21:59:20.013 3331-3435/com.example.quickstart I/barentries1: 000000000002842 
07-24 21:59:20.017 3331-3435/com.example.quickstart I/barentries1: 000000000001796 
07-24 21:59:20.020 3331-3435/com.example.quickstart I/barentries1: 000000000003658 
07-24 21:59:20.023 3331-3435/com.example.quickstart I/barentries1: 000000000001965 
07-24 21:59:20.025 3331-3435/com.example.quickstart I/barentries1: 000000000000796 
07-24 21:59:20.027 3331-3435/com.example.quickstart I/barentries1: 000000000007631 
07-24 21:59:20.029 3331-3435/com.example.quickstart I/barentries1: 000000000006323 
07-24 21:59:20.032 3331-3435/com.example.quickstart I/barentries1: 000000000000496 
07-24 21:59:20.033 3331-3435/com.example.quickstart I/barentries1: 000000000003531 
07-24 21:59:20.035 3331-3435/com.example.quickstart I/barentries1: 000000000002313 
07-24 21:59:20.037 3331-3435/com.example.quickstart I/barentries1: 000000000000954 
07-24 21:59:20.040 3331-3435/com.example.quickstart I/barentries1: 000000000005071 
机器值为,机器后的值:

07-24 22:00:14.244 3639-3709/com.example.quickstart I/machines: TEMP-2 
07-24 22:00:14.249 3639-3709/com.example.quickstart I/machines: TEMP-3 
07-24 22:00:14.254 3639-3709/com.example.quickstart I/machines: TEMP-1 
07-24 22:00:14.257 3639-3709/com.example.quickstart I/machines: BENTLER-1 
07-24 22:00:14.263 3639-3709/com.example.quickstart I/machines: BENTLER-2 
07-24 22:00:14.265 3639-3709/com.example.quickstart I/machines: DEMAN 
07-24 22:00:14.267 3639-3709/com.example.quickstart I/machines: ANNE-LOSE 
07-24 22:00:14.269 3639-3709/com.example.quickstart I/machines: TEMP-3 
07-24 22:00:14.272 3639-3709/com.example.quickstart I/machines: ANNEALD-1 
07-24 22:00:14.274 3639-3709/com.example.quickstart I/machines: TEMP-1 
07-24 22:00:14.276 3639-3709/com.example.quickstart I/machines: BENTLER-1 
07-24 22:00:14.278 3639-3709/com.example.quickstart I/machines: DEMAN 
07-24 22:00:14.280 3639-3709/com.example.quickstart I/machines: ANNE-LOSE 

什么是barEntries和barEntries 1。您可以发布它的值并匹配数组吗?所以我可以在Android Studio中运行它。我已经编辑了我的帖子。@MishaAkopov你能在Android Studio中运行它吗?如果需要,请询问任何其他信息。
07-24 22:00:14.244 3639-3709/com.example.quickstart I/machines: TEMP-2 
07-24 22:00:14.249 3639-3709/com.example.quickstart I/machines: TEMP-3 
07-24 22:00:14.254 3639-3709/com.example.quickstart I/machines: TEMP-1 
07-24 22:00:14.257 3639-3709/com.example.quickstart I/machines: BENTLER-1 
07-24 22:00:14.263 3639-3709/com.example.quickstart I/machines: BENTLER-2 
07-24 22:00:14.265 3639-3709/com.example.quickstart I/machines: DEMAN 
07-24 22:00:14.267 3639-3709/com.example.quickstart I/machines: ANNE-LOSE 
07-24 22:00:14.269 3639-3709/com.example.quickstart I/machines: TEMP-3 
07-24 22:00:14.272 3639-3709/com.example.quickstart I/machines: ANNEALD-1 
07-24 22:00:14.274 3639-3709/com.example.quickstart I/machines: TEMP-1 
07-24 22:00:14.276 3639-3709/com.example.quickstart I/machines: BENTLER-1 
07-24 22:00:14.278 3639-3709/com.example.quickstart I/machines: DEMAN 
07-24 22:00:14.280 3639-3709/com.example.quickstart I/machines: ANNE-LOSE