MPAndroidChart如何设置X比例

青春须早为,岂能长少年。这篇文章主要讲述MPAndroidChart如何设置X比例相关的知识,希望能为你提供帮助。
一天好的同志,我使用MPandroidChart库绘制价格变化的线性图表,具体取决于时间。使用Y刻度,没有问题,但我无法使X刻度正常工作。根据位置,有水可以用这个比例代替所需的值:

IAxisValueFormatter formatter = new IAxisValueFormatter() { @Override public String getFormattedValue(float value, AxisBase axis) { return quarters[(int) value]; } ; XAxis xAxis = mLineChart.getXAxis(); xAxis.setGranularity(1f); xAxis.setValueFormatter(formatter);

但是存在一个问题,计划在加载结束时由加载器进行整理,并且开始时间是用户想要查看结果的时间段的选择。如果在10分钟内看到结果 - 那么服务器的数量少于10个,如果一天,超过100个。问题是为什么值没有更新,当我需要看100个值后回到10,它看起来在轴列表Y的值为100,当然,找不到它们因为我们只有10个要崩溃。实际上问题是如何重置这些值?在将数据传输到图表之前,我做了mChart.clear(); 但它没有帮助。我不明白肮脏的把戏。请帮忙理解。
答案一般来说,我决定这样做:我写了格式化程序并在其中:
@Override public String getFormattedValue(float value, AxisBase axis) { if (value > = list.size()) { value = https://www.songbingjia.com/android/list.size() - 1; } Date date = new Date(list.get((int) value) * 1000); return formatter.format(date); }

【MPAndroidChart如何设置X比例】有人能派上用场吗?

    推荐阅读