Firnaz
Firnaz

Reputation: 552

MPAndroidchart : xaxis labels leaves more empty space at bottom

I want the xaxis labels to come down. Those large labels pushes the graph on top where i am not able to view the graph itself as shown in the figure given below. There is lot of space between the xaxis labels and legends(Legends not shown in figure below). I want to overcome this and view the chart. Find my code below

    barChart.getAxisLeft().setAxisMinimum(-1.0f);

    barChart.getAxisLeft().setDrawGridLines(false);
    barChart.getAxisRight().setDrawGridLines(false);
    barChart.getAxisRight().setEnabled(false);
    barChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
    barChart.getXAxis().setDrawGridLines(false);
    barChart.getXAxis().setLabelRotationAngle(-90.0f);
    barChart.getXAxis().setLabelCount(12);
    barChart.getXAxis().setCenterAxisLabels(true);
    barChart.getXAxis().setGranularityEnabled(true);
    barChart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(xAxisLabelList));

    barChart.getXAxis().setAxisMaximum(12f);
    barChart.groupBars(1f, 0.5f, 0f);
    barChart.invalidate();

Bar chart

Upvotes: 1

Views: 1527

Answers (1)

Ammar Tahir
Ammar Tahir

Reputation: 312

You can use barChart.setExtraBottomOffset(-10f); to reduce extra white-space below labels. And increase your chart height in xml file.

barChart

Upvotes: 3

Related Questions