4

I am trying to create a Piechart in my android app. this link using achartengine helped. But I still have a problem. I want to display the % of distribution in the pie chart itself

Thanks in advance.

Community
  • 1
  • 1

2 Answers2

3

I was also looking for the same. But see the answer given by Dan here. I suppose he is the guy behind AChartEngine and he says that the names of legends and Labels cannot be different.

Update:

Although what I did to over come this was, that I made the legend size as 0. Then in the label I set the label and the computed percentage together. So, in your case, the labels would turn out to be:

Mg+ : 23%

Na+ : 45% ...so on.

Update:2

This issue for present in version 1.0.0 and has been solved in the latest version 1.1.0-rc2 version. You can download it from here. Now as @Dan says it here, we can have different Legend and Label values. We can also use:

renderer.setDisplayValues(true);

to displays the percentage distribution in the pie chart itself.

Community
  • 1
  • 1
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124
  • 1
    Yeah! Thanks... That would help to customize the legend but I want to display the '%' near or over the pie chart. Could you pls suggest something for this too. – Sivaguru Jambulingam Mar 18 '13 at 04:47
  • 1
    http://stackoverflow.com/questions/13657432/how-to-set-different-values-for-legend-and-labels-in-piechart-while-i-am-using-c/15471237#15471237 See this link. It could be done!! – Sivaguru Jambulingam Mar 18 '13 at 06:57
  • Yes. Thanks for pointing that out :) The facility became available in the latest version now. I've updates the answer as well. – Shobhit Puri Mar 18 '13 at 07:07
-1

In order to get the details in % form, you can use the following :

renderer.setChartValuesFormat(NumberFormat.getPercentInstance());
Jad
  • 479
  • 2
  • 10
  • 23
krunal patel
  • 2,369
  • 1
  • 11
  • 11