Anusha
Anusha

Reputation: 9

Displaying x- axis label in bar chart using MPAndroidChart is not working as expected

X-axis values are getting overlap and i need to make it exactly below to the bar

https://i.sstatic.net/5uNDq.png`

BarDataSet dataSet = new BarDataSet(barEntryArrayList, "Invoice Qty");
        BarData lineData = new BarData(dataSet);
        chart.setFitBars(true);
        XAxis xAxis =chart.getXAxis();
        xAxis.setValueFormatter(new AxisValueFormatter(labels));
        xAxis.setGranularityEnabled(true);
        xAxis.setGranularity(1f);
       /* xAxis.setSpaceMax(lineData.getBarWidth() / 2f);
        xAxis.setSpaceMin(lineData.getBarWidth()/2f);*/
        //xAxis.setLabelRotationAngle(-120f);
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setCenterAxisLabels(true);
        YAxis yAxisRight = chart.getAxisRight();
        yAxisRight.setEnabled(false);
        chart.setData(lineData);
        chart.getDescription().setEnabled(false);
        chart.invalidate();`

Upvotes: 0

Views: 353

Answers (1)

Kona Suresh
Kona Suresh

Reputation: 1854

xAxis.setLabelRotationAngle(45f);

It is working for me. I am using latest version 3.0.3

Upvotes: 1

Related Questions