Javascript examples for highcharts:Pie Chart
remove decimal places for pie chart
<html> <head> <title>Highcharts Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <script src="https://code.highcharts.com/modules/export-data.js"></script> <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div> <script type="text/javascript"> var chart1 = Highcharts.chart('container', { chart: {//from w w w. ja va2 s . c o m events: { load: function() { // on complete var chart1 = this; var xpos = '50%'; var ypos = '50%'; var circleradius = 40; chart1.renderer.circle(xpos, ypos, circleradius).attr({ fill: '#fff', }).add(); chart1.renderer.text(Math.round(chart1.series[0].data[0].percentage) + '%', 62, 80).css({ width: circleradius * 2, color: '#4572A7', fontSize: '16px', textAlign: 'center' }).attr({ zIndex: 999 }).add(); } }, plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' }, title: { text: 'Browser market shares in January, 2018' }, tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, format: '<b>{point.name}</b>: {point.percentage:.1f} %', style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' } } } }, series: [{ name: 'Brands', colorByPoint: true, data: [{ name: 'Chrome', y: 61.41, sliced: true, selected: true }, { name: 'Internet Explorer', y: 11.84 }, { name: 'Firefox', y: 10.85 }, { name: 'Edge', y: 4.67 }, { name: 'Safari', y: 4.18 }, { name: 'Sogou Explorer', y: 1.64 }, { name: 'Opera', y: 1.6 }, { name: 'QQ', y: 1.2 }, { name: 'Other', y: 2.61 }] }] }); </script> </body> </html>