How to set the x-axis label with MPAndroidChart

后端 未结 4 1204

I use MPAndroidChart for my app like this:

but I can not add tag like that

4条回答
  •  自闭症患者
    2020-12-17 16:48

    You can override AxisValueFormatter

    i.e.:

    xAxis.setValueFormatter(new AxisValueFormatter() {
                @Override
                public String getFormattedValue(float value, AxisBase axis) {
                    return "YOUR_TEXT"; // here you can map your values or pass it as empty string
                }
    
                @Override
                public int getDecimalDigits() {
                    return 0; //show only integer
                }
            });
    

    You can pick center value of the group to map the group name, others are empty. that would be the easiest way.

提交回复
热议问题