0
votes

I am using mpandroidchart in my android app. I am facing some issues.

enter image description here

As you can see, there is a part of graph shown below lower datum of bars(area where 'Description' is displayed).This issue is there only when one of the Y value is 0 as in this case. How to get rid of it?Also, how to get rid of 'Description'?

Another issue is as:

enter image description here

Here you can see several issues. First, a large part of the view is empty below the X labels(When X labels are big I need to rotate it so that all labels are dsplayed,otherwise graph only displays alternate labels on X axis). I want graph to occupy as much space as possible. But it occupies only a part of it. Second issue here is the height of graphs. They are quite disproportionate. I want uniform heights of bar proportional to their values(like in first picture.

1

1 Answers

3
votes

By removing the description, the extra area will go off. Try to remove the description by setting barChart.setDescription("");.

If not worked, try

YAxis yAxisLeft = barChart.getAxisLeft(); yAxisLeft.setAxisMinValue(0f);

YAxis yAxisRight = barChart.getAxisRight(); yAxisRight.setAxisMinValue(0f);

For second one, you need to set the chart minimum height to fill the area. android:layout_height="match_parent" won't work for MPAndroidChart.

Set barChart.setMinimumHeight(height);

For graph uniform height try this:

YAxis yAxisLeft = barChart.getAxisLeft(); yAxisLeft.setAxisMinValue(0f);

YAxis yAxisRight = barChart.getAxisRight(); yAxisRight.setAxisMinValue(0f);

By setting the axis minimum value to zero, the chart will draw from zero and you will get the uniform height.