make a pie chart responsive - Javascript highcharts

Javascript examples for highcharts:Pie Chart

Description

make a pie chart responsive

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <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> 
      <style id="compiled-css" type="text/css">

#container-independency {/* w w w  .j  a  v  a2  s  . co m*/
   width: 90%;
   max-width: 1620px;
   background-color: #b8860b;
   clear: both;
   padding: 1%;
   box-sizing: border-box;
}
#independency {
   width: 80%;
   margin-left: auto;
   margin-right: auto;
   padding: 1%;
   background-color: #ffb6c1;
   box-sizing: border-box;
}
#highcharts_container {
   width: 100%;
   margin-left: auto;
   margin-right: auto;
   box-sizing: border-box;
}


      </style> 
      <script type="text/javascript">
$(function () {
    var independency = 100;
    $('#highcharts_container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false,
            type: 'pie'
        },
        title: {
            text: ''
        },
        credits: {
            enabled: false
        },
        navigation: {
            buttonOptions: {
                enabled: false
            }
        },
        tooltip: {
            pointFormat: '<b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.2f} %',
                    style: {
                        color: '#58585a',
                        fontFamily: 'klavika-web, sans-serif',
                        fontSize: '12px'
                    }
                }
            }
        },
        series: [{
            name: '',
            data: [
                ['Property1aaa/<br>Property2aaa/<br>Property3aaaaaa', independency],
                ['More blablabla<br> blablabla', 100 - independency], ]
        }]
    }); //highcharts_container
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container-independency"> 
         <div id="independency"> 
            <div>
               Title plot
            </div> 
            <div style="margin-left: 2.8%; margin-top:1%; font-size: 24px;">
               Bla blablabla blab bl
               <span class="autarkie"> </span>
                % blabla = 
               <strong> 
                  <span class="autarkie"> </span>
                   % blablabla blablabla
               </strong> 
            </div> 
            <div id="highcharts_container"></div> 
         </div> 
      </div>  
   </body>
</html>

Related Tutorials