Create Multiple pie charts from json - Javascript highcharts

Javascript examples for highcharts:Pie Chart

Description

Create Multiple pie charts from json

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function () {// w  ww. j  a v a 2s  . c o  m
    var json = [{
        "name": "Drive",
            "data": ["C:", "D:", "E:", "F:"]
    }, {
        "name": "Free",
            "data": [673869, 2267920, 105627, 307096]
    }, {
        "name": "Used",
            "data": [94029, 2264810, 6373, 104]
    }];
    var each = Highcharts.each,
        $charts = $('#charts');
    each(json,function(item, i) {
        $charts.append('<div id="container' + i + '"></div>');
        var $chart = $('#container' + i);
        $chart.highcharts({
           chart:{
               type:'pie'
            },
            series:[{
               name: item.name,
                data: item.data
            }]
        });
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="charts"></div>  
   </body>
</html>

Related Tutorials