MP Android Chart 中的 xAxis getAxisLabel(value: Float, axis: AxisBase?) 值显示负数 -1

发布于 2025-01-18 03:23:45 字数 1127 浏览 5 评论 0原文

如何解决Xaxis mpcharts中值为-1的问题?由于这个问题,我在Xaxis中的第一个数组没有显示。

 inner class MyAxisFormatter : IndexAxisValueFormatter() {

    override fun getAxisLabel(value: Float, axis: AxisBase?): String {
        var xValue = ""
        val index = value.toInt()
        Log.d("Main Activity", "value: " + value)
        xValue = if (index < Month_AmountArrayList.size && index > 0) {
            Month_AmountArrayList[index].month

        } else {
            ""
        }
        return xValue


    }
}

数组中的2个元素:

“

logcat中的输出:

“

电话中的输出:

“”

图表输出未显示JAN

How to solve the problem where the value in xAxis Mpcharts is -1? Because of this problem, my first array in xAxis is not showing.

 inner class MyAxisFormatter : IndexAxisValueFormatter() {

    override fun getAxisLabel(value: Float, axis: AxisBase?): String {
        var xValue = ""
        val index = value.toInt()
        Log.d("Main Activity", "value: " + value)
        xValue = if (index < Month_AmountArrayList.size && index > 0) {
            Month_AmountArrayList[index].month

        } else {
            ""
        }
        return xValue


    }
}

2 elements in the array:

element object

The output in logcat:

logcat output

The output in phone:

chart output not showing Jan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文