问题描述
如何设置条形图在组合图中的一个数据居中。
当我有多个数据时:
还有一个数据:
val xAxis = chart.xAxis
xAxis.position = XAxis.XAxisPosition.BottOM
xAxis.setDrawGridLines(false)
xAxis.axislinewidth = 1f
xAxis.gridlinewidth = 0.1f
xAxis.axisMinimum = 0f
xAxis.granularity = 1f
xAxis.textColor = textColor
xAxis.textSize = 10f
xAxis.setCenteraxisLabels(true)
xAxis.setLabelCount(4,true)
xAxis.setDrawGridLinesBehindData(false)
代码格式化程序:
xAxis.valueFormatter = object : ValueFormatter() {
override fun getFormattedValue(value: Float): String {
if (value < 0) {
return ""
}
val index = value.toInt()
val dto = reverseListData.getorNull(index)
return if (dto?.time?.isEmpty() == true) {
if (currentChartTime == YEAR_1 || currentChartTime == YEAR_3) {
dto.TradeDate.split("-")[0].convertRest2UIDateYM()
} else {
dto.TradeDate.split("-")[0].convertRest2UIDate()
}
} else {
Log.d("Time",dto?.time?.convertRestTime2UITimeHM() ?: "")
dto?.time?.convertRestTime2UITimeHM() ?: ""
}
}
}
如果我的代码具有if(值
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)