I have a stacked bar chart whose entries are added from a database. The code is something like this:yVals.add(new BarEntry(new float[]{v1, v2, v3}, xIndex)); where v1, v2 and v3 are values got from the database.
My problem some times, the value of v2 or v3 is 0 so when I add the entry to the chart, the bardata label for that field(which is 0) overlaps the previous stack's(v1 or v2) bardata label.
Is there any option to disable the label only for 0 values?
Thanks.
P.S. I have attached an image showing the label being overlapped in the 3rd yellow stack, 6th green stack and 7th green stack.

Edit: I found a solution for this. Just add a statement in the ValueFormatter saying return an empty string if the value is 0.
For example,
public String getFormattedValue(float value) {
if(value==0)
return "";
else
return mFormat.format(value);
}
Hi
I need the same requirement to remove 0 values in Stacked bar chart.I used your suggestion but still I could see the 0 values in my chart.
Below is my code snippet
leftAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
String stringVal;
if (value == 0.0 | value ==0) {
stringVal = "";
}
else {
stringVal = String.valueOf(value);
}
return stringVal;
}
});
Do you have any idea?
Regards
Divya
Most helpful comment
Edit: I found a solution for this. Just add a statement in the ValueFormatter saying return an empty string if the value is 0.
For example,
public String getFormattedValue(float value) {
if(value==0)
return "";
else
return mFormat.format(value);
}