2
votes

I am making a PieChart in android studio but am running into some issues with styling. The size of description (and legend and values are really small). I read the docs about this and it said there i had to use the setDescriptionTextSize() method and that it is available for every chart type.
However that method is not resolved for some reason.

extra info about project:
-the problem occurs in a fragment
-my pieChart is built in the "onChildAdded" method because it needs to be created when that function runs.
-the MPAndroidChart version is: v3.0.3

Here is my code:

pieChart = (PieChart) myView.findViewById(R.id.idPieChart);
pieChart.setCenterTextSize(25f);
pieChart.setUsePercentValues(true);
pieChart.setExtraOffsets(5, 10, 5, 5);
pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(Color.WHITE);
pieChart.setTransparentCircleRadius(61f);
pieChart.setEntryLabelTextSize(25f);
pieChart.setUsePercentValues(true);
pieChart.setDescriptionTextSize(25f);  //THIS IS NOT RESOLVED

List<PieEntry> entries = new ArrayList<>();

entries.add(new PieEntry(likeCount.getLikes(), "Leuk"));
entries.add(new PieEntry(likeCount.getDislikes(), "Niet leuk"));
PieDataSet set = new PieDataSet(entries, "likes/dislikes");
PieData data = new PieData(set);
set.setColors(getResources().getColor(R.color.chartgreen)
                ,getResources().getColor(R.color.chartred));
pieChart.setData(data);
pieChart.invalidate(); // refresh

Does anyone know a possible solution to this problem?

2

2 Answers

1
votes

The value has to be between 6f and 16f. Other values aren't accepted.

setDescriptionTextSize(float size): Sets the size of the description text in pixels, min 6f, max 16f.

1
votes

you can use

pieChart.getDescription().setTextSize(25f);

instead of

pieChart.setDescriptionTextSize(25f);