Mazz
Mazz

Reputation: 257

MPAndroidChart - Horizontal bar chart - Justify label text to the left

I'm using MPAndroidChart to create a horizontal bar graph.

Is it possible to justify the label text from the left as opposed to the right?

enter image description here

Code:

mChart.getXAxis().setValueFormatter(new LabelValueFormatter(set1));
            mChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
            mChart.getXAxis().setXOffset(100);

Upvotes: 0

Views: 3047

Answers (2)

Mazz
Mazz

Reputation: 257

Setting the axis position to the TOP and reversing the offset worked:

mChart.getXAxis().setValueFormatter(new LabelValueFormatter(set1));
mChart.getXAxis().setPosition(XAxis.XAxisPosition.TOP);
mChart.getXAxis().setXOffset(-350);

Upvotes: 1

Shabnam Esmaeili
Shabnam Esmaeili

Reputation: 74

you can set to draw the values above the bars by:

mChart.setDrawValueAboveBar(true);

the result is like this image.

Upvotes: 0

Related Questions