Create several charts using different data but same options - Javascript highcharts

Javascript examples for highcharts:Chart Data

Description

Create several charts using different data but same options

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts test tool</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-git.js"></script> 
      <script type="text/javascript">
    $(function(){/*w w w  .j  a  va  2 s.c om*/
$(document).ready(function() {
    var baseConfig = {
        credits: {
            enabled: false
        },
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage}%</b>',
            percentageDecimals: 1
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    formatter: function() {
                        return '<b>'+ this.point.name +'</b>: '+ this.y;
                    }
                }
            }
        }
    };
    var data1 = {title: {
            text: 'One'
        },
        series: [{
            name: 'Space',
            type: 'pie',
            data: [
                ['Used',  30],
                ['Free',  70],
            ]
          }]};
    var data2 = {title: {
            text: 'Two'
        },
        series: [{
            name: 'Space',
            type: 'pie',
            data: [
                ['Used',  60 ],
                ['Free',  40],
            ]
                }]};
   var data3 = {title: {
            text: 'Three'
        },
        series: [{
            name: 'Space',
            type: 'pie',
            data: [
                ['Used',  10 ],
                ['Free',  90],
            ]
                  }]};
    $('#container1').highcharts(
        $.extend(baseConfig, data1)
    );
    $('#container2').highcharts(
        $.extend(baseConfig, data2)
    );
    $('#container3').highcharts(
        $.extend(baseConfig, data3)
    );
});
    });

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container1" style="height: 300px"></div> 
      <div id="container2" style="height: 300px"></div> 
      <div id="container3" style="height: 300px"></div>  
   </body>
</html>

Related Tutorials