Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying percentage inside pie item for highcharts

I am trying to figure out if it is possible to display the percentage for each pie item inside the actual pie item for highcharts? Example of what I mean is something like this:

https://developers.google.com/chart/interactive/docs/gallery/piechart

like image 736
ryanzec Avatar asked Sep 21 '12 11:09

ryanzec


People also ask

How do I show percentage in Highcharts?

log(this) return Math. round(this. percentage)+'%'; } }, series: [{ type: 'column', data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], name: 'Temperature' },] }); Now, on mouse over it returns "NaN%", can you tell me why it is like that or how to fix it?

How do you show percentage data for a pie chart?

To display percentage values as labels on a pie chart The data labels should appear within each slice on the pie chart. On the design surface, right-click on the labels and select Series Label Properties. The Series Label Properties dialog box appears. Type #PERCENT for the Label data option.

How do you show percentage data?

Percentages are calculated by using the equation amount / total = percentage. For example, if a cell contains the formula =10/100, the result of that calculation is 0.1. If you then format 0.1 as a percentage, the number will be correctly displayed as 10%.


2 Answers

You may want to look @ dataLabels.formatter. this.percentage option is available for pie

Also dataLabels.distance can be set to a negative value for dataLabels inside the pie.

Pie with percentage values inside @ jsFiddle

like image 153
Jugal Thakkar Avatar answered Sep 30 '22 01:09

Jugal Thakkar


Its suprisingly easy. In your tooltip or dataLabels section change your format.

FROM:
  format: '<b>{point.name}</b>: {point.y:.1f} Rs.',
TO:
  format: '<b>{point.name}</b>: {point.percentage:.1f} %',
like image 28
Mark Avatar answered Sep 30 '22 02:09

Mark