I need to hide the value above bars in MPAndroidChart for barchart. I have tried all the methods available in it , but could not find the solution.
Asked
Active
Viewed 2.4k times
27
-
Is there any method to hide the visibility of whole BAR ? Visibility GONE or INVISIBLE ? – Jaimin Modi Jan 11 '22 at 05:23
2 Answers
92
Try dataSet.setDrawValues(false)
. This will prevent any values from being drawn.
In case you want to alter (customise) the drawn values (or only individual values), you can use the ValueFormatter interface and implement your own logic (e.g. hide specific values based on a condition). Always keep in mind performance is critical when using the ValueFormatter
.

Philipp Jahoda
- 50,880
- 24
- 180
- 187
-
Hi Philipp, I have a stackBar Chart. I want to display one value on top of the bar chart and not for each stack of the bar. Can this be done using MpAndroidchart library? – Komal Gupta Apr 01 '16 at 09:58
-
can you help me here https://stackoverflow.com/questions/45230343/how-to-remove-lines-if-values-is-0-in-pie-chart – gaurang Jul 21 '17 at 06:25
-
-
How can I add toggle values to lineChart? `dataSet.setDrawValues(false)` hides the values. I need to tap on every circle and showing a custom view(the value and date). How can I achieve this? – Amir Shabani Oct 14 '17 at 11:50
-
Is there any method to hide the visibility of whole BAR ? Visibility GONE or INVISIBLE ? – Jaimin Modi Jan 11 '22 at 05:22
3
If you want to hide values by condition, you can use a Formatter. Here is an example:
You have to call this method:
dataSet.setDrawValues(true)
and your have add a condition to your formatter:
public class MyYAxisValueFormatter implements IAxisValueFormatter {
private DecimalFormat mFormat;
public MyYAxisValueFormatter() {
// format values to 1 decimal digit
mFormat = new DecimalFormat("###,###,##0");
}
@Override
public String getFormattedValue(float value, AxisBase axis) {
String val = ""
if ((int)value > 10){
val = value
}
return mFormat.format(val);
}
/** this is only needed if numbers are returned, else return 0 */
/*@Override
public int getDecimalDigits() { return 1; }*/
}
If you want to hide all of the values you can use this:
dataSet.setDrawValues(false)

Stypox
- 963
- 11
- 18

Jean Carlos Ramos Cruz
- 81
- 1
- 4
-
Is there any method to hide the visibility of whole BAR ? Visibility GONE or INVISIBLE ? – Jaimin Modi Jan 11 '22 at 05:22