Mpandroidchart: Piechart align left position

Created on 27 Jul 2015  路  8Comments  路  Source: PhilJay/MPAndroidChart

Hi, i would like to align the pie chart circle to the left instead of center. Is there a way to do that (i have tryied to mess with setX but nothing happens)? Thanks in advance.

All 8 comments

Remove all the offsets and give it some right margin.

Thanks for answering, i have tryied those, but none of them seems to work:

    chart.offsetLeftAndRight(0);
    chart.setExtraOffsets(0,0,0,0);
    chart.getCircleBox().offset(0,0);

Which offset i must remove? Thanks in advance.

Have you figured out @sagits

nobody helps here

Same problem here, does anyone have solution?

Finally i have found the way
This will align text to right and circle to left

Legend l = pieChart.getLegend();
l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_CENTER);

OR with new version

        Legend l = pieChart.getLegend();
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.VERTICAL);

Hi there! Same issue here...someone had solution for this issue?

@rgaraisayev Your solution doesn't works

You can set

Legend legend = pieChart.getLegend();
legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_INSIDE);

pieChart.setExtraRightOffset(110f);

This will move the circle to the left of the screen and put the legend at the right. The only problem here is that the legend starts from the top instead of being centered in the middle.

The other option is to set

legend.setPostion(Legend.LegendPostion.RIGHT_OF_CHART_CENTER);

without setting an offset.

Here the chart is set to the right at a specific distance to the legend. The problem here is that if you change the length of the legends, the position of the circle will change a bit. A solution would be to figure out how much difference there is between the legend lengths and change the offset accordingly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OnlyInAmerica picture OnlyInAmerica  路  3Comments

botondbutuza picture botondbutuza  路  3Comments

vishvendu picture vishvendu  路  3Comments

AndroidJiang picture AndroidJiang  路  3Comments

SutharRohit picture SutharRohit  路  3Comments