我也是初次了解使用这个控件完成项目,然后发现X轴数据不准确,debug查看了数据发现X轴会出现float类型数据。查询一些文章,也没找到解决方法。我就去看了下API文档,发现AxisBase类中setLabelCount方法
public void setLabelCount(int count, boolean force) { setLabelCount(count); mForceLabels = force; }
这个方法中的force参数解释
@param force if enabled, the set label count will be forced, meaning that the exact specified count of labels will be drawn and evenly distributed alongside the axis - this might cause labels to have uneven values如果启用,将强制设置标签计数,这意味着确切指定的标签计数将被强制执行 (true)
绘制并沿着轴均匀分布——这可能导致标签具有不均匀的值 (false)
然后我将参数修改为false之后
发现X轴显示非常完美。
新手一枚,有不同见解的欢迎留言。