Javascript examples for highcharts:Pie Chart
get the 2 decimal places in pie chart
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from www .j a v a2 s . c o m $(function() { Highcharts.setOptions({ colors: ['#8edce7', '#e8ebeb'] }); // Create the chart for completion var chart_completion = new Highcharts.Chart({ chart: { renderTo: 'my-account', type: 'pie', events:{ load:function(){ var chart = this, series = chart.series[0], firstPoint = series.data[0].y, nextPoint = series.data[1].y, percent = (firstPoint/nextPoint), value = 0; //console.log(firstPoint); //console.log(nextPoint); chart.setTitle({ text: (percent*100).toFixed(2) + '%' }); } } }, tooltip: false, exporting: { enabled: false }, plotOptions: { pie: { dataLabels: { enabled: false }, states: { hover: { enabled: false } }, } }, title: { align: 'center', verticalAlign: 'middle' }, credits: { enabled: false }, series: [{ data: [ ["Remaining Credit (USD)", 1540015685], ['Total Credit (USD)', 2000000000] ], innerSize: '80%' }] }); }); } </script> </head> <body> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="my-account" style="display:inline-block;"></div> </body> </html>