Javascript examples for highcharts:Pie Chart
set plot for pie chart
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(function () {//w ww.j a v a2 s. c o m function setTranslation(p, slice){ p.sliced = slice; if(p.sliced){ p.graphic.animate(p.slicedTranslation); } else { p.graphic.animate({ translateX: 0, translateY: 0 }); } } var data = [ 100, 68, 20, 30, 100 ]; var options = { chart: { renderTo:'container', plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' }, title: { text: 'Browser market shares January, 2015 to May, 2015' }, tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { point: { events: { mouseOut: function () { setTranslation(this, false); }, mouseOver: function() { setTranslation(this, true); } } }, allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, format: '<b>{point.name}</b>: {point.percentage:.1f} %', style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' } } } }, series: [] } var seriesOptions = { name:'Metric', data:[], colorByPoint: true, } for(i=0;i<data.length;i++){ var dataOptions = { name:'', y:'' } dataOptions.name = 'metric'+i; dataOptions.y = data[i]; seriesOptions.data.push(dataOptions); } options.series.push(seriesOptions); var chart = new Highcharts.Chart(options); }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div> </body> </html>