Open GrishmaPromact opened 7 years ago
Did you find any solution ?
@tutysathish No till now. :(
I have exactly the same problem, both with this library and with the iOS one, so I thought that it wasn't a bug but a miss configuration of the legend. I hope you find a solution.
@rferbesa I don't have any solution. If you have any solution then please suggest me. Thanks.
@GrishmaPromact @tutysathish @rferbesa
Hi,
I found a solution.
Call the following method on your PieChart:
piecPieChart.setExtraBottomOffset(20f);
The method takes a float
value, which represents the offset of the Chart's viewport from the Bottom.
Hi how u set your legend / labels vertically ? ? pls share
@engr-erum I didn't find any solution.
Thanks alot for this post @GrishmaPromact , I spent half day searching for legends to be vertically aligned. After i did these changes, i faced the same issue of cutting legend as this
Set the following, l.setYOffset(10f);
Increase the value as per requirement
Thanks , it worked @aviraj
customizing with xml attribute android:translationY="-10dp"
OR view.setExtraOffsets(...);
you can manage dp accordingly.
l.setYOffset(10f);
yay... worked.
thanks,i have this problem,too.
My legend isn't showing my 6th entry . I have written this code -
public void makePieChart() {
ArrayList
yValues.add(new PieEntry(avgCount, EXPLAIN_TREATMENT));
yValues.add(new PieEntry(avgCount, WAITING_TIME));
yValues.add(new PieEntry(avgCount, RECEPTIONIST_POLITE));
yValues.add(new PieEntry(avgCount, DENTIST_FRIENDLY));
yValues.add(new PieEntry(avgCount, CLINIC_CHAMBER_CLEAN_HYGENIC));
yValues.add(new PieEntry(avgCount, BILLS_NOT_GIVEN));
// yValues.add(new PieEntry(poorCount, "Poor"));
PieDataSet dataSet = new PieDataSet(yValues, "");
dataSet.setSliceSpace(6f);
dataSet.setSelectionShift(6f);
dataSet.setColors(ColorTemplate.COLORFUL_COLORS);
pieChart.animateY(500);
Legend l = pieChart.getLegend();
PieData data = new PieData(dataSet);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setForm(Legend.LegendForm.CIRCLE);
l.setXEntrySpace(10f);
l.setYEntrySpace(0f);
l.setYOffset(30f);
l.setWordWrapEnabled(true);
l.setDrawInside(false);
l.getCalculatedLineSizes();
data.setValueTextSize(40f);
data.setValueTextColor(Color.BLACK);
pieChart.setData(data);
pieChart.highlightValues(null);
pieChart.invalidate();
}
here is the screenshot of my UI -
As, you are facing horizontal legends cutting. Set X offset for horizontally cutting legend.
Set the following,
l.setXOffset(10f);
Increase the value as per your requirement
As, you are facing horizontal legends cutting. Set X offset for horizontally cutting legend. Set the following, l.setXOffset(10f);
Increase the value as per your requirement
@GrishmaPromact yeah that solved my cutting issue. But can u tell, why i am unable to see my 6th entry in legend?
@anant-dev pieChart.setEntryLabelTextSize(12f); you can reduce the text size and also decrease the Yoffset to 30f to 20f and check. I am not sure.
@anant-dev pieChart.setEntryLabelTextSize(12f); you can reduce the text size and also decrease the Yoffset to 30f to 20f and check. I am not sure.
@GrishmaPromact I tried setting textSize using above method , doesnt seem to work @PhilJay Can you help ?
This issue is easily reproducible in the example app. In PieChartActivity comment out these two lines to move the legend underneath the pie chart
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
and you'll see Party D is clipped
This issue also occurred in the iOS repo, which I reported and they fixed.
A workaround that worked for both libraries is to mess with the legend's yOffset
and the pie chart's extraBottomOffset
until it works for your legend. Would be good to fix this issue for android!
Sorry, I might be late by years. But we should also make sure we do the following before we set data and invalidate it.
legend().setWordWrapEnabled(true);
// Should you wish to set the size
legend().setTextSize(getResources().getDimension(R.dimen.text_sub_heading));
// Should you wish to set the form size
legend().setFormSize(CHART_LEGEND_FORM_SIZE);
// and then
chart.invalidate();
I have attached the screenshot of my usage chart. In red box display the legends and they are cutting in pie chart. Below is my code:
plz help me to solve this issue. Thanks in advance.