Mpandroidchart: How to customize y axis range.

Created on 10 Oct 2017  路  8Comments  路  Source: PhilJay/MPAndroidChart

@nielsz @PhilJay
I want to add a $ sign.
68747470733a2f2f7261772e6769746875622e636f6d2f5068696c4a61792f4d5043686172742f6d61737465722f73637265656e73686f74732f63756269636c696e6563686172742e706e67

All 8 comments

class YAxisValueFormatter implements IAxisValueFormatter {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return value+"$";
}
}

mYAxis.setValueFormatter(new YAxisValueFormatter());

close issue if it works

@ithemant09
One more thing, can i change y axis values difference because it gives automatically like if i want 30$,40$ and 50$. Thanks :+1:

@pj210493
you may try this, but I am not very sure.
mYAxis.setLabelCount(6, true);
mYAxis.setAxisMaximum(50f);
mYAxis.setAxisMinimum(0f);

@ithemant09
No its not working. I have already tried.

@pj210493
Working with sample code provided in Github, must be some other problem in your code.

device-2017-10-11-195016

@pj210493 yes, problem in your code.

I think he mean how to change the step between two values, you, you change the max value and the number of values but if he have values > 50 this is not a good idea

@pj210493
you may try this, but I am not very sure.
mYAxis.setLabelCount(6, true);
mYAxis.setAxisMaximum(50f);
mYAxis.setAxisMinimum(0f);

Thank you bro, you save me...
Here for Kotlin user, I hope anybody can solve...

chart1 is id from XML Layout (I use view binding on android)

chart1.xAxis.labelCount = 1
        chart1.xAxis.mAxisMaximum = 30.toFloat()
        chart1.xAxis.mAxisMinimum = 0.toFloat()
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChenZeFengHi picture ChenZeFengHi  路  3Comments

andreyfel picture andreyfel  路  3Comments

AndroidJiang picture AndroidJiang  路  3Comments

DarkHelmet67 picture DarkHelmet67  路  3Comments

OnlyInAmerica picture OnlyInAmerica  路  3Comments