如何在MPAndroidChart中向x和y轴添加字符串标签 [英] How to add String labels to both x and y axis in MPAndroidChart
本文介绍了如何在MPAndroidChart中向x和y轴添加字符串标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图添加一个字符串标签,以便同时标记我的LineChart
的域(x轴)和范围(y轴),如下图所示.
I am trying to add a String Label in order to label both the domain (x-axis) and the range (y-axis) of my LineChart
, as shown in the picture below.
关于如何使用MPAndroidChart进行操作的任何建议?
Any suggestions on how to do it using MPAndroidChart?
推荐答案
您可以应用此代码
mChart.getAxisLeft().setEnabled(true); //show y-axis at left
mChart.getAxisRight().setEnabled(false); //hide y-axis at right
mChart.getAxisLeft().setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return "string_" + (int) value; // yVal is a string array
}
});
这篇关于如何在MPAndroidChart中向x和y轴添加字符串标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文