在MPAndroidChart中,我可以用setSkipLabels控制xaxis值的频率。但是,这只会影响xaxis。如何对线图中的线条本身做同样的处理?
发布于 2016-04-25 06:54:39
我不认为库为LineDataSet提供了一种简洁的方法,就像X轴一样。最好的选择是使用自定义ValueFormatter将文本设置为空白。
举个例子显示十个标签中的一个:
public class MyValueFormatter implements ValueFormatter {
private DecimalFormat mFormat;
public MyValueFormatter() {
mFormat = new DecimalFormat("###,###,##0.0"); // use one decimal
}
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
String output = "";
if (entry.getXIndex() % 10 == 0) output = mFormat.format(value);
return output;
}
}
然后,将格式化程序附加到DataSet上。
lineDataSet.setValueFormatter(new MyValueFormatter());
这只会影响在图中每个值旁边显示的文本。
还可以使用以下方法禁用在每个值上绘制圆圈:
lineDataSet.setDrawCircles(false);
https://stackoverflow.com/questions/36810135
复制