PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.68k stars 9.02k forks source link

Pie Chart: Legend vertical orientation to the right of pie chart is not working. #2478

Open durgatjb opened 8 years ago

durgatjb commented 8 years ago

I want to set the legends to the right of Pie Chart in vertical orientation. I used the below code: // legend customization Legend legend = mBinding.pieChart.getLegend(); legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_CENTER); legend.setForm(Legend.LegendForm.CIRCLE); // set what type of form/shape should be used legend.setXEntrySpace(8f); legend.setYEntrySpace(6f); legend.setXOffset(0f);

XML: <com.github.mikephil.charting.charts.PieChart android:id="@+id/pie_chart" android:layout_width="match_parent" android:layout_height="match_parent" />

akhilz commented 6 years ago

Please help, having the same issue

afinas-em commented 6 years ago

Use this code :

Legend legend = pie_chart.getLegend();
legend.setVerticalAlignment(Legend.LegendVerticalAlignment.CENTER);
legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
legend.setOrientation(Legend.LegendOrientation.VERTICAL);
legend.setDrawInside(false);
bdiegel commented 6 years ago

RIGHT or CENTER horizontal alignment with VERTICAL orientation - NOT WORKING LEFT horizontal alignment with VERTICAL orientation - WORKS FINE (v3.0.3 )

    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
    l.setOrientation(Legend.LegendOrientation.VERTICAL);
mak1nt0sh commented 4 years ago

To set in top and center you need to use: chart.legend.verticalAlignment = Legend.LegendVerticalAlignment.TOP chart.legend.horizontalAlignment = Legend.LegendHorizontalAlignment.CENTER