为了绘制折线图,我从服务器获取数据,该数据基于财政年度,即四月至三月。我在xAxis上绘制月份,在yAxis上绘制值。现在我的问题是我具有2019年12月和2020年1月的价值,但是当我在图表上绘制时,一月显示为第一个值,十二月显示为最后一个值,而我想绘制一月值在十二月值之后是不同的年份。我从api中获得了year的值,但是我不明白如何在图表中使用它。
我也像这样从1月到12月获得month的整数值
if (month == 1f) {
return getString(R.string.january)
} else if (month == 2f) {
return getString(R.string.february)
} else if (month == 3f) {
return getString(R.string.march)
} else if (month == 4f) {
return getString(R.string.april)
} else if (month == 5f) {
return getString(R.string.may)
}....
我正在使用上面的代码来获取xAxis的标签。
如何正确考虑绘制年份的时间。
这就是我创建数据集的方式
values.add(Entry(historyModel.monthId.toString().toFloat(),
String.format("%.2f",historyModel.collectionAmount.toFloat()).toFloat()))