[英]Customsing x-axis labels in android-graphview
I am using android-graphview to display bar graph in android app. 我正在使用android-graphview在android应用中显示条形图。 On X-axis I want to display labels as 'day-of-the-week,hour-of-the-day' like 'Mon,14.00'.
在X轴上,我希望将标签显示为“一周中的一天,一天中的小时”,例如“周一,14.00”。 So original x value(it may be date or time in milliseconds) in data point is totally done away with.
因此,完全消除了数据点中的原始x值(可能是日期或时间(以毫秒为单位))。 I know we can do some customization in setLabelFormatter, but as far as I understand you can do some append to original value, not totally remove it.
我知道我们可以在setLabelFormatter中进行一些自定义,但是据我了解,您可以对原始值做一些附加,而不是完全删除它。 Is there a way out for it?
有办法吗?
use the DefaultLabelFormatter
override the format method and call the super implementation. 使用
DefaultLabelFormatter
覆盖format方法并调用super实现。 then you can append your text to the string. 那么您可以将文本附加到字符串中。
Example: 例:
graph.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter() {
@Override
public String formatLabel(double value, boolean isValueX) {
if (isValueX) {
// show normal x values
return super.formatLabel(value, isValueX);
} else {
// show currency for y values
return super.formatLabel(value, isValueX) + " €";
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.