Florin Oiță
Florin Oiță

Reputation: 113

MPAndroid Chart , how do i format values on chart from floats to ints, interface is depricated

enter image description here

Hello , I want to format the values from the Line Chart , from the current floats into ints, I found that the library specifies the usage of the ValueFormatter interface , link to git repo of the library but it is deprecated so i cannot use it anymore , any ideas how I could do it? Thanks

This is how it should have looked I suppose:

dataSet.setValueFormatter(new ValueFormatter() {
    @Override
    public String getFormattedValue(float value, AxisBase axis) {
        return super.getFormattedValue(value, axis);
    }
});

Upvotes: -1

Views: 695

Answers (1)

Md. Asaduzzaman
Md. Asaduzzaman

Reputation: 15423

Use getFormattedValue(float value) instead of getFormattedValue(float value, AxisBase axis) either on LineDataSet or LineData like below:

dataSet.setValueFormatter(new ValueFormatter() {
    @Override
    public String getFormattedValue(float value) {
        return String.valueOf((int)value);
    }
});

I have tested on v3.1.0

Upvotes: 3

Related Questions