Reputation: 73
so basicly recently I started programming mobile apps and found a problem in my application. I want XAxis values of my line chart in 19:30 format, not 3244 minutes passed format, so I googled AxisFormatters. The problem is, in all of the tutorials they make class like this:
private class MyAxisFormatter implements IAxisValueFormatter {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return value as an hour;
}
}
and then put it in function:
XAxis valAxis = mChart.getXAxis();
valAxis.setValueFormatter(new MyAxisFormatter());
But whenever I impement it into this I got red underline saying: Required type: ValueFormatter Provided: MyAxisFormatter
I tried to cast it somehow to ValueFormatter but that didnt work, solution that program prompts me is to make MyAxisFormater extend ValueFormatter although i dont get any errors then that doesnt change any value on my XAxis
Upvotes: 4
Views: 1439
Reputation: 73
Ok I got it, instead of using
private class MyAxisFormatter implements IAxisValueFormatter {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return value as an hour;
}
}
I used
private class MyAxisFormatter extends ValueFormatter {
@Override
public String getFormattedValue(float value) {
return "someValue";
}
}
And everything works fine
Upvotes: 3