Are0215
Are0215

Reputation: 131

Is there a way to hide value labels for each bar on bar chart in MPAndroidChart?

I am using MPAndroidChart. I need to hide value label put above bar on my BarChart. How can i do this?

Example image

Upvotes: 6

Views: 3588

Answers (2)

Philipp Jahoda
Philipp Jahoda

Reputation: 51421

Yes, there is a way.

Just call

dataSet.setDrawValues(false);

Upvotes: 16

sb6847
sb6847

Reputation: 92

https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartLib/src/com/github/mikephil/charting/renderer/BarChartRenderer.java

Line 316 is where the label is drawn. So you can comment that out in your library. It's easy to do if you're using the actual library as a library but if you're just using it as a dependency in your gradle file or using a jar file I'm not sure if you can't easily hide it.

Look at Line 176 of that file. That's where the drawing label starts.

You can change the position of the label based on this variable drawValueAboveBar which I think you can set easily.

The other thing you can do is make the paint it's using the draw's color TRANSPARENT.

use the mValuePaint.setColor() method and set its color to transparent.

Upvotes: -1

Related Questions