Javascript examples for highcharts:Bar Chart
format data label for bar chart
<html> <head> <title>percent</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.1.js"></script> <script type="text/javascript"> $(function(){/*w ww .j a v a 2 s . c om*/ var data = [7,12,16,32,64]; var dataSum = 0; for (var i=0;i < data.length;i++) { dataSum += data[i] } var chart = new Highcharts.Chart({ chart: { renderTo:'container', type:'bar' }, title:{ text:'Chart Title' }, credits:{enabled:false}, legend:{ }, plotOptions: { series: { shadow:false, borderWidth:0, dataLabels:{ enabled:true, formatter:function() { var pcnt = (this.y / dataSum) * 100; return Highcharts.numberFormat(pcnt) + '%'; } } } }, xAxis:{ lineColor:'#999', lineWidth:1, tickColor:'#666', tickLength:3, title:{ text:'X Axis Title' }, }, yAxis:{ lineColor:'#999', lineWidth:1, tickColor:'#666', tickWidth:1, tickLength:3, gridLineColor:'#ddd', title:{ text:'Y Axis Title', rotation:0, margin:50, }, labels: { formatter:function() { var pcnt = (this.value / dataSum) * 100; return Highcharts.numberFormat(pcnt,0,',') + '%'; } } }, series: [{ data: data }] }); }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/highcharts-more.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="height:400px;margin:1.5em 1em;"></div> </body> </html>