Open durgatjb opened 8 years ago
Please help, having the same issue
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);
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);
To set in top and center you need to use:
chart.legend.verticalAlignment = Legend.LegendVerticalAlignment.TOP chart.legend.horizontalAlignment = Legend.LegendHorizontalAlignment.CENTER
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" />