MPAndroidChart 中出现IAxisValueFormatter数组越界错误

这个问题出现在我来回切换chart的数据,刷新chart,导致数组越界

解决的fang方法

chart.getXAxis().setValueFormatter(new IAxisValueFormatter() {
    @Override
    public String getFormattedValue(float value, AxisBase axis) {
        int index = (int) value;
        if (index < 0 || index >= xValues.size()) {
            return "";
        } else {
            return xValues.get(index);
        }
    }
    
});

判读一下value的值是否小于x轴的size

猜你喜欢

转载自blog.csdn.net/qq_30711091/article/details/81109516
今日推荐